AI-Lab Practical Systems Kata & Benchmark Kit (CLI + 10 Multi-Stage Drills)
10 multi-stage Python systems engineering katas, O(N) scaling benchmarks, and CLI grader — paired with a free browser Web Worker sandbox.
Engineering interviews at AI labs and infrastructure startups have shifted away from abstract dynamic programming brainteasers toward multi-stage practical systems coding: building rate limiters, stateful caches, DAG schedulers, log aggregators, and Merkle sync primitives from scratch in 45–60 minutes.
Why this problem wastes time
Candidates routinely burn weeks memorizing isolated graph puzzles only to fail practical engineering rounds for predictable implementation reasons:
- Clock and PRNG non-determinism: Calling
time.time()orrandom.random()directly inside a rate limiter or retry policy makes unit testing timing edges painful and hides negative clock-skew bugs. - Sentinel and boolean traps: Treating
cache.get(key) is Noneas a miss drops cachedNonevalues, while checkingisinstance(val, int)in Python accidentally acceptsTrueandFalse. - Hidden
O(N^2)regressions: Scanning an entire cache or trie on every write passes small 10-item toy tests, then stalls under 5,000-item workloads. - Stage 2/3 state breakage: Adding rollback transactions,
:paramroutes, or half-open probe caps often corrupts Stage 1 invariants when tests are not run progressively.
Step-by-step workflow
Use a repeatable three-stage drill loop whenever practicing practical systems components:
- Inject clocks, PRNGs, and cryptographic hashes from line one. Accept
clock=time.monotonicandrng=random.Random()in constructors, and usehashlib.sha256instead of Python's per-process saltedhash(). - Guard failure paths atomically. Verify capacity and dual-quota checks before mutating token balances; clamp
elapsed = max(0.0, now - last_ts)against clock skew; keep_MISSING = object()sentinels for missing keys. - Verify each stage independently before scaling up. Lock in Stage 1 correctness first, then layer Stage 2 (reservations, LRU/TTL eviction, cycle detection) and Stage 3 (dual quotas, nested rollback, subtree pruning), followed by a
N=100vsN=5000scaling ratio check usingpython kata_runner.py init 01_llm_token_bucket --workspace ./workspace,python kata_runner.py test 01_llm_token_bucket --stage 1 --workspace ./workspace,python kata_runner.py test 01_llm_token_bucket --stage all --workspace ./workspace, andpython kata_runner.py bench 01_llm_token_bucket --workspace ./workspace.
Automating it in seconds
You can practice Kata 01 (Multi-Tenant Token Bucket Rate Limiter) right away in the free browser sandbox on index.html, which runs 6 deterministic injected-clock tests inside an isolated Web Worker with a 1500ms timeout guard.
For full offline interview prep, the AI-Lab Practical Systems Kata & Benchmark Kit ($7.00) packages the zero-dependency Python 3.10+ kata_runner.py CLI (list, init, test, bench, grade-all), all 10 three-stage systems katas (01_llm_token_bucket through 10_decorrelated_retry), HINTS_AND_TRAPS.md, N=100 vs N=5000 scaling ratio benchmarks, and JSON/Markdown scorecards.