fix: v0.5.3 server/pool stability wave (7 P0/P1 defects + regression tests)#51
Merged
Merged
Conversation
…round - SRV-1 (CRITICAL): server re-resolves the engine per request via an injected engineProvider; GUI cold-swap no longer answers with the wrong model or bricks with 500s on a frozen engine reference - SRV-2 (CRITICAL): model swap + generation are atomic under the generation lock (beginGeneration helper); load can no longer race an in-flight generation on shared MLX state - SRV-3: lock acquire/release now share one lexical scope (streaming: inside ResponseBody); cancellation-aware waiter queue removes the permanent-leak and dead-owner deadlocks - SRV-4: stall-based generation watchdog (generationStallTimeoutSeconds, default 120s, 0 = disabled) — bounds the hang presentation from issue #29 (non-streaming buffered forever with no server timeout) - POOL-1: active model is pinned (unpin previous, same-model guard); dangling currentModel reconciled when a failed load evicted it - POOL-2: Stop now cancels engine generation (onTermination + honored .terminated + Task.isCancelled in both LLM/VLM loops) - POOL-3: evict(toFit:) skips isGenerating entries; server generations are marked in-flight via the new inFlightHook - A1: streaming unknown-model requests return 404 before headers again (OpenAI SSE, Ollama chat+generate NDJSON, Anthropic SSE) - A4: stall-timeout clamped (0...86400s) against Double→UInt64 traps 7 regression tests cover the exact escape mechanisms: loadHook swap, concurrent dual-model, cancelled parked waiter, watchdog + lock release, pin/unpin ordering, evict guard, streaming 404 pre-flight.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This was referenced Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes 7 confirmed P0/P1 defects found by a 4-agent debug round against main
5e461fb(full findings tracked internally; issue #29's hang mechanism is bounded by the new watchdog).CRITICAL
engineProviderre-resolves the current engine per request.ensureModelLoadedran outside the generation lock, so a concurrent swap could interleave with an in-flight generation (wrong-model output / load racing generation on shared MLX state). Swap + generate are now atomic under the lock (beginGeneration).HIGH
generationStallTimeoutSeconds(default 120s, 0 = disabled) — inter-chunk stall detection, so long productive generations are never killed. Streaming unknown-model requests also return 404 before headers again (4 paths).currentModelwith UI showing ready. Active model is now pinned (same-model reload guard) and the dangling pointer is reconciled.onTermination→ task cancel →Task.isCancelledin the engine loops).evict(toFit:)ignoredisGeneratingand server generations were invisible to the pool. Evict now skips in-flight entries; the server marks generations in-flight viainFlightHook.Tests
7 new regression tests target the exact escape mechanisms (loadHook swap, concurrent dual-model, cancelled parked waiter, watchdog + lock release, pin/unpin ordering, evict guard, streaming 404): 65 XCTest + 178 swift-testing, 0 failures; app + CLI builds green. Independently code-reviewed (APPROVE).