BuildSeniorBackendAuto-graded
Build a token-bucket limiter that returns 429
Implement a token bucket to spec. It allows a burst, refills over time, and lets exactly capacity callers through under concurrent load.A service needs a rate limiter in front of it.SPEC.md has the contract and limiter.py already has the HTTP handler wired up; the TokenBucket class is yours to write. It has to work for any capacity and refill interval, and stay correct when many threads call allow() at the same moment.45 min
python
You're done when
- A full bucket allows exactly
capacityrequests and refuses the next one. - Tokens come back over time: a request refused a moment ago goes through once the bucket has refilled.
allow()stays exactly correct when many threads call it at once: exactlycapacityrequests get through, never more.- The endpoint answers 200 while tokens remain and 429 once they run out.
What it measures
Thread safetyWhether `allow()` stays correct when many threads call it at the same time.
Reading the specHow closely the build follows `SPEC.md`, edge cases and the HTTP contract included.
TestingWhether you test beyond the provided smoke tests, concurrent calls included, before you finish.
Agent directionHow you steer your coding agent and check the code it writes.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
45 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo