Code Room
Vibe codingHard
Question
An AI agent wrote this C++ for a game server's hit-registration cache, claiming it "safely memoizes per-frame so concurrent worker threads share results":
std::unordered_map<EntityId, HitResult> cache; HitResult getHit(EntityId id, const World& w) { auto it = cache.find(id); if (it != cache.end()) return it->second; HitResult r = computeHit(id, w); // expensive cache[id] = r; return r;}Workers call `getHit` from multiple threads. The agent's single-threaded test passes. What's wrong, and how do you verify it before it ships into a 128-tick server?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.