Code RoomGraceful shutdown with background workers
HardPrep Room Coding #4053

Graceful shutdown with background workers

Vibe & agenticAlgorithms & data structuresSenior–Staff~20 min

You ask an AI agent to 'add graceful shutdown to our Go HTTP service.' It wires `signal.Notify` and calls `server.Shutdown(ctx)` with a 5s timeout — looks textbook. In a load test, in-flight requests get cut and a background worker pool keeps running after the process is 'done.' You re-prompt 'make shutdown actually wait'; it bumps the timeout to 30s. It doesn't see the second component that needs draining. How do you re-steer to a correct shutdown?

Implement
plan_shutdown_drain(components: list[str], drain_ms: list[int], budget_ms: int) → list[str]
Examples
in[["http","workers","metrics","db"],[2000,15000,500,300],25000]out["http=drained","workers=drained","metrics=drained","db=drained"]
in[["http","workers","metrics","db"],[2000,15000,500,300],5000]out["http=drained","workers=cut","metrics=abandoned","db=abandoned"]
in[["http"],[2000],5000]out["http=drained"]
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.

0:00 of about 20 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.