Skip to content

fix: remove Swift 6 captured-var warnings in Server startup - #185

Merged
solderzzc merged 1 commit into
mainfrom
fix/swift6-captured-vars
Sep 25, 2026
Merged

solderzzc merged 1 commit into
mainfrom
fix/swift6-captured-vars

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Three startup vars were captured by concurrently-executing closures. Today that's a warning; in the Swift 6 language mode it's an error:

Site (main 804616e) var Why it's a var
Server.swift:1337 isVision the VLM→LLM fallback (#173) flips it after a failed VLM load; read in /health
Server.swift:1056, :1368 mtpAssistantModelRef assigned after the assistant loads; read in container.perform and in the chat route

Each is now captured through a let snapshot taken after its last mutation: loadedAsVision, loadedMTPAssistant, and a local assistant for the mainModelRef wiring. DualModelMTP is class-bound (via Module), so setting through the let still reaches the same object. No behaviour change.

Verified

  • Clean rebuild (Xcode 27 / Swift 6.4): no captured-var warnings remain.
  • Mac mini M6 smoke test: unsloth/Qwen3.6-35B-A3B-UD-MLX-4bit (VLM fallback) returns /health "vision":false, Qwen3.8-27B-4bit returns "vision":true, and Gemma 4 with --mtp --mtp-assistant-model …assistant-bf16 prints MTP assistant ready (3 tokens/round). All three answer a request.

Independent of #183; the hunks don't overlap.

🤖 Generated with Claude Code

Three `var`s were captured by concurrently-executing closures, which is a
warning today and an error in the Swift 6 language mode:
- Server.swift:1337 `isVision`: made mutable by the VLM→LLM fallback (#173)
  and read in the /health handler.
- Server.swift:1056 / 1368 `mtpAssistantModelRef`: read inside
  `container.perform` and in the chat-completion route.

Each is now captured through a `let` snapshot taken after its last mutation
(`loadedAsVision`, `loadedMTPAssistant`, and a local `assistant` for the
mainModelRef wiring; DualModelMTP is class-bound via Module, so setting
through the `let` still reaches the same object).

Clean rebuild on Xcode 27 / Swift 6.4 shows no captured-var warnings. Smoke-tested on a
Mac mini M6: Qwen3.6-35B (VLM fallback) /health "vision":false, Qwen3.8-27B
"vision":true, Gemma 4 + bf16 MTP assistant "MTP assistant ready (3 tokens/round)",
and all three answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@solderzzc

Copy link
Copy Markdown
Member Author

Reviewed (code-review skill, M5 agent): no issues found. Both snapshots are taken after the last write: isVision is last set at the VLM fallback (line 936) and mtpAssistantModelRef at line 1050. Every later read uses the let copies, so behavior is unchanged. I'll merge once CI is green.

@solderzzc
solderzzc merged commit 554c431 into main Sep 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant