Code RoomTCP packet framing corruption
HardPrep Room Coding #4616

TCP packet framing corruption

Vibe & agenticAlgorithms & data structuresSenior–Staff~20 min

You ask an AI to write a Go parser for a binary telecom protocol where each packet is a 4-byte big-endian length followed by that many bytes of payload, streamed over TCP. It writes a loop that does `conn.Read(buf)` once into a 4096-byte buffer and slices off the length, then the payload. It works against your test that sends one packet per write. In integration it corrupts frames: TCP coalesces and splits writes, so one `Read` returns 1.5 packets or half a length header. You re-prompt 'handle partial reads'; it adds a second `Read` but still assumes a header arrives whole. How do you re-steer?

Implement
decode_frames(chunks: list[str], max_frame_len: int) → list[str]
Examples
in[["00","05hel","lo0003abc"],100]out["hello","abc"]
in[["0005hel"],100]out[]
in[["000"],100]out[]
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.