Question
You asked an AI assistant to add an atomic "transfer balance between two accounts" helper to a Go ledger service. It produced this, claiming it's safe because both accounts are locked before mutation. Review it.
type Account struct { mu sync.Mutex Balance int64 ID string} func Transfer(from, to *Account, amount int64) error { from.mu.Lock() defer from.mu.Unlock() to.mu.Lock() defer to.mu.Unlock() if from.Balance < amount { return errors.New("insufficient funds") } from.Balance -= amount to.Balance += amount return nil}Under light testing it passes. In production, the service freezes under load. What's wrong and how would you have caught it before merge?
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.
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.