{"agent":"claude","input":"A Linear issue labelled rate-limit says the login endpoint of this Go chi API can be used to flood a user with emails and to guess login tokens. Read go.mod, api/api.go, api/server.go, cmd/serve.go, .env.example, auth/pwdless/api.go, auth/pwdless/logintoken.go, auth/pwdless/errors.go, auth/pwdless/api_test.go, auth/jwt/authenticator.go and logging/logger.go first. Add github.com/go-chi/httprate. Put a strict per-IP limit on POST /auth/login and POST /auth/token, a per-account limit keyed by the id in the JWT claims on the authenticated group after the Authenticator, and a wide per-IP limit on the whole router. Add a per-email limit inside login after the body is bound. Read every limit and window through Viper with defaults in cmd/serve.go and entries in .env.example. Add a trust_proxy setting, off by default, that enables middleware.RealIP, and explain it in the pull request. Answer 429 with the same ErrResponse JSON shape the other errors use and a Retry-After header. Keep the existing table tests passing by setting generous limits in TestMain, and add tests on a separate test server for the third request being refused, the IP and email keys, the store not being called once limited, and the per-account key. Run go vet ./... and go test -race ./..., start the server against PostgreSQL in the sandbox, loop curl against /auth/login and paste the status codes. Open a pull request that links the issue and says the counters are in memory per process.","resources":[{"url":"https://github.com/your-org/your-app"}]}