4 months ago
f4906eeThe concurrency cap counted children, then awaited several times before registering the new binding. Concurrent spawn() calls (e.g. a model emitting N spawnAgent calls executed in parallel) all observed the same pre-registration count and all passed, exceeding MAX_ACTIVE_CHILDREN_PER_PARENT and weakening the fork-bomb guard (flagged by Cursor Bugbot on PR #159). Reserve a slot synchronously at the (now combined registered + in-flight) check, before any await, and release it in a finally once the binding is registered or the spawn fails. Splits the post-check body into spawnReserved(). Adds a parallel-spawn regression test that fails without the reservation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Parent590dc5b