Files
Matt Nye d07bb6cd77 fix(supervisor): parked slot-waiters follow the live concurrency cap; a provider switch restarts a parked generator (#3909)
waitForSlot captured CLAUDE_MEM_MAX_CONCURRENT_AGENTS once per waiter, so a
settings raise never released a parked generator, and a provider change only
logged "will switch after current generator finishes" — which a parked
generator never does (the idle monitor only runs once a slot is held). Live
result: six of seven sessions parked behind a cap of 1, and reverting the
provider setting processed nothing until a worker restart dropped ~426 items.

- process-registry: waitForSlot(number | () => number, signal?, sessionId?)
  re-invokes the getter on every recheck; slotWaiters carry sessionId /
  parkedSince / warnedParked; getParkedSlotWaiterCount and
  isSessionParkedForSlot exported; one WARN per waiter parked > 3 min
- ClaudeProvider: pass a settings-reading getter plus the session id
- SessionRoutes: a provider change aborts a PARKED generator
  (abortReason 'provider_switch'), awaits its exit chain, then restarts on
  the new provider via the shared admitAndStartGenerator path; mid-response
  generators unchanged; ensureGeneratorRunning serialised per sessionDbId
  (promise-map mutex) to close the concurrent double-start race;
  normalizeAbortReason + enum listings + telemetry docs gain provider_switch
- GeneratorExitHandler: provider_switch preserves the buffer like quota
- DataRoutes: /api/processing-status gains parkedSessions (additive)
- tests: parked-waiter release/FIFO/cap, provider-switch-while-parked,
  exit-handler, processing-status, double-start serialisation; shared
  singleton guards for the process registry and the quota-cooldown breaker,
  wired at top level in every file that drives them

Tests: 48 pass / 0 fail across the six affected files (800/0 under
--rerun-each=20); tsc clean; full suite's failing set unchanged versus the
clean base. A rare cross-test timeout in the provider-switch suite is
disclosed in the PR body.



Claude-Session: https://claude.ai/code/session_01RJEKSU5eVwnvBf4irjtP4E

Co-authored-by: Gwen Ives <gwen.ives@nyecorp.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 18:01:12 -07:00
..