Log inBook a Demo
BuildSeniorBackendAuto-graded

Build a token-bucket limiter that returns 429

Working to a precise written spec: allow a burst of traffic, refuse the rest, stay correct under simultaneous requests.A service is being hammered by a handful of noisy clients, and the limiter in front of it lets bursts through. Implement a token bucket in limiter.py against the written contract in SPEC.md — one that stays exactly correct when requests arrive simultaneously, not only when they arrive one at a time.
45 min
python

You're done when

  • A full bucket allows exactly capacity requests and refuses the next one.
  • Tokens refill over time, so a request refused a moment ago succeeds once the bucket has recovered.
  • Under simultaneous load exactly capacity requests get through — the token check and the decrement happen as one atomic step.
  • The HTTP layer answers 200 while tokens remain and 429 once they are gone.

What it measures

Concurrency reasoningChoosing a lock granularity that keeps check-and-decrement atomic without serialising the hot path.
Spec fidelityReading a written contract closely enough to hit its boundary behaviour, not just its happy path.
Verification instinctProving the fix under simultaneous load instead of trusting a single-threaded pass.
Agent directionSteering the coding agent at the failing invariant rather than accepting a rewrite.

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