185
mutex
Only one holder enters. It is not a suggestion, and it does not work across processes unless you bought a distributed lock.
What is mutex?
A mutex (mutual exclusion) lets one thread hold a critical section. It lives in one process unless it is a database or distributed lock. A boolean flag is not a mutex. Forgetting to unlock on every path, including errors, deadlocks the next caller.
Why does mutex matter when vibe coding?
Models write `if (!locked) { locked = true }` . Two threads both pass. Name a real lock and a `finally` that releases it.
How do you do mutex?
Use the language’s lock. Keep the section tiny. Release in finally. If you need the lock across processes, use a database constraint or a lock with a lease, not a memory flag.
How do you ask a model for mutex?
Protect (section) with a mutex, not a boolean. Release it on every exit including errors. Keep the critical section free of network calls. Do not pretend an in-process lock works across instances.
What goes wrong with mutex?
A distributed lock without a lease. The holder dies and the lock stays. Every lock needs an expiry and a fencing token.