An AI assistant can fix a race condition and wreck your throughput in the same diff, and the tests will still pass. That is the trap: correctness and design intent are not the same thing, and most prompts only ask for the first one.
The Details:
- When a model is told to kill a flaky concurrent test, its only measurable goal is a green checkmark. It does not know your fan-out job was built to hit ten APIs at once on purpose. So it reaches for the safest tool: a lock, a shrunk worker pool, or a
Promise.all quietly unrolled into a sequential loop of awaits. Same calls, same order, same results, zero rate-limit errors. Also ten times slower.
- The giveaway is in the model's own explanation. Phrases like "to ensure ordering" or "to prevent the race" show up even when the original design never needed ordering. That language rationalizes a regression instead of describing an architectural choice, and it slides past review because the code reads as idiomatic and clean.
- The fix is to make concurrency a stated requirement, not an assumption. Specify in the prompt which calls must run in parallel, which results can arrive in any order, and which single piece of shared state actually needs protection. A model cannot reach for a global lock if your own instructions already rule one out.
- Make parallelism visible in the code itself. Named helpers instead of raw concurrent constructs, a comment flagging a section as concurrent, and one timing assertion on the handful of stages where speed is the point will catch a sequential rewrite the moment it is proposed, not after a scheduled job has quietly tripled in duration.
Bottom Line: Tests verify output, not design, so if parallelism matters you have to write it down, name it, and time it, or an AI fix will trade your performance for a passing checkmark without telling you.