Repository navigation
fix(provider): scan the configured model cache in darkbloom switch - #1566
Conversation
`Switch` loads its snapshot with `loadRuntimeSnapshot(configPath:)`, which does not apply `model_cache_directory` to `ModelScanner`. With a non-default directory, `switch --model` rejected every local model and the picker listed installed models as downloads. Apply the directory as the `configOptions` overload does. Closes Layr-Labs#1469 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo
|
@javiech1 is attempting to deploy a commit to the EigenLabs Team on Vercel. A member of the Team first needs to authorize it. |
Threat model review — advisoryReviewed head Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (1 batches); openai/gpt-6.1-sol: not needed by escalation policy No actionable findings in the reviewed text. This is not a security approval. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Scan completed. Coverage: 23/23 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.7321 reported, $0.0000 reserved with unknown cost; 8 paid request(s), 0 reused batch(es), 61075 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. |
The merge adds #1566, #1591, #1602, #1605, #1606, #1607, #1612, #1621, #1622, #1623, #1625, #1629, #1630, #1631, #1632 (provider 0.10.4), #1633, #1644, #1652 and #1653 to this branch. Conflicts and resolutions: - CoordinatorClient+Connection.swift: #1606 moves the transport setup out of connectAndRun into the static function connectionParameters(for:), and puts the connectAndRun header below it. This branch adds the session parameter to the same header. The merge keeps the layout of master. The moved header has the signature of this branch: connectAndRun(_ session: CoordinatorSessionRecorder). Git merged the other changes without a conflict: the bounded handshake of master (CoordinatorConnectionHandshake.start) and the session recorder of this branch (markOpened after register, the session parameter of sessionLoop and receiveLoop, and the close-code read). - docs/provider/cli-reference.md: the runtime constants table. The merge keeps the three reconnect rows and the ping/pong row of this branch. It adds the handshake deadline row of master after the ping/pong row, where master has it. - docs/provider/troubleshooting.md: only the "Last updated" stamp had a conflict (2026-10-26 on this branch, 2026-10-27 on master). The merge keeps one stamp, 2026-10-27. Git merged the rows: the backoff citation of this branch and the new rows of master. Each decision has one owner after the merge: - CoordinatorReconnectPolicy chooses the wait before the next connection attempt, after each end of a session or of an attempt. - CoordinatorConnectionHandshake (#1606) cancels a handshake that does not complete in 30 s. runLoop catches the timeout error. That attempt did not send register, so the policy gives the next backoff range, as on master. - UnauthorizedConnectionRecovery (#1607, #1633) decides when to start a re-registration of a connection that the coordinator refuses. Its retry backoff counts re-registrations, not connection attempts, and an authorized verdict sets that count to zero. The re-registration closes the session. Then the policy chooses the wait, as for each other end. Checks: against master, the merge has only the changes of this branch, in its 15 files. The troubleshooting stamp is the one exception: it has the date of master. Against this branch, the merge has only the changes of master, in 651 files. The one exception is the connectAndRun header, which has the session parameter. The gitlinks do not change: libs/mlx 31f550af, libs/mlx-swift 4926d3d9, libs/mlx-swift-lm aee6ebb6. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Summary
With a non-default
[backend] model_cache_directory,darkbloom switch --model …rejected every local model as "missing or unsupported", and the interactive picker listed installed models under "Available to download".Switch.runloads its snapshot withloadRuntimeSnapshot(configPath:), which, unlike theconfigOptionsoverload, never applies the configured directory toModelScanner, so the scan fell back to~/.cache/huggingface/hub. The fix applies it right after loading the snapshot, as the other commands do. This is the cause @frindle traced in the issue.Linked issue
Closes #1469
Test plan
SwitchCommandTests.explicitSelectionScansTheConfiguredModelCache: aCLICommandSandboxprovider whose config points at a non-default cache holding onegpt_ossmodel, thenswitch --modelfor it. Without the fix it fails withSelection rejected; missing or unsupported local model(s): acme/Switch-mxfp4; with it the selection passes (the command then stops at the update lock in the test runner's directory, before writing any request).swift test --skip-build --filter DarkbloomCLITests: 596 tests, all pass exceptStartServingGuardTests"startup preload reports its result…", which fails identically on unmodifiedmasteron this Mac (a provider is running on it).make changelog-check docs-check docs-impact-check.mastercf3c45107. The branch sits onb09a332b3because my fork token cannot push the newer.github/workflowschange; the touched files are identical on both, and it merges cleanly intomaster.Components touched
Protocol / interface changes
Documentation impact
docs/provider/cli-reference.md,darkbloom switch: the command scans the daemon config'smodel_cache_directory)Changelog
changelog.d/<topic>.mdfragment and ranmake changelog-check.Notes for reviewers
ModelScanner.configureCacheDirectoryis process-wide, which is howloadRuntimeSnapshot(configOptions:)already works forstart,modelsanddoctor;switchis a one-shot CLI process, so setting it once there is enough for both the explicit scan and the picker.Before And After
flowchart LR classDef bad fill:#fde2e2,stroke:#c62828,color:#3b0d0d classDef good fill:#e3f4e8,stroke:#2e7d32,color:#0d2b14 classDef neutral fill:#e3ecfa,stroke:#1565c0,color:#0b2140 subgraph Before B0["switch: loadRuntimeSnapshot(configPath:)"]:::neutral --> B1["ModelScanner scans ~/.cache/huggingface/hub"]:::bad --> B2["Selection rejected / picker shows downloads"]:::bad end subgraph After A0["switch: loadRuntimeSnapshot(configPath:)"]:::neutral --> A1["configureCacheDirectory(model_cache_directory)"]:::good --> A2["local models found; switch request sent"]:::good endRefactor Pass
Two source lines; no structural change. Re-ran the
SwitchCommandTestssuite (7 tests) after the final edit.🤖 Generated with Claude Code
https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo
Need help on this PR? Tag
@codesmith-botwith what you need.