Skip to content

fix(provider): scan the configured model cache in darkbloom switch - #1566

Merged
Gajesh2007 merged 1 commit into
Layr-Labs:masterfrom
javiech1:fix/switch-model-cache-directory
Oct 27, 2026
Merged

Gajesh2007 merged 1 commit into
Layr-Labs:masterfrom
javiech1:fix/switch-model-cache-directory

Conversation

@javiech1

@javiech1 javiech1 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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.run loads its snapshot with loadRuntimeSnapshot(configPath:), which, unlike the configOptions overload, never applies the configured directory to ModelScanner, 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

  • New exit test SwitchCommandTests.explicitSelectionScansTheConfiguredModelCache: a CLICommandSandbox provider whose config points at a non-default cache holding one gpt_oss model, then switch --model for it. Without the fix it fails with Selection 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 except StartServingGuardTests "startup preload reports its result…", which fails identically on unmodified master on this Mac (a provider is running on it).
  • make changelog-check docs-check docs-impact-check.
  • Tests ran on master cf3c45107. The branch sits on b09a332b3 because my fork token cannot push the newer .github/workflows change; the touched files are identical on both, and it merges cleanly into master.

Components touched

  • provider-swift (Swift CLI)
  • native runtime / MLX
  • landing (Next.js)
  • enclave (Swift)
  • CI / provider release
  • docs

Protocol / interface changes

  • No protocol/interface changes
  • Yes — described above and matching side updated

Documentation impact

  • Canonical documentation updated (docs/provider/cli-reference.md, darkbloom switch: the command scans the daemon config's model_cache_directory)
  • No documentation needed — reason:

Changelog

  • Added or updated this PR's unique changelog.d/<topic>.md fragment and ran make changelog-check.
  • No user-visible change, or an explicitly authorized release/history change.

Notes for reviewers

ModelScanner.configureCacheDirectory is process-wide, which is how loadRuntimeSnapshot(configOptions:) already works for start, models and doctor; switch is 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
  end
Loading

Refactor Pass

Two source lines; no structural change. Re-ran the SwitchCommandTests suite (7 tests) after the final edit.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

`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
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown

@javiech1 is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 524969721559 against base cf3c4510722a.

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.

@Gajesh2007
Gajesh2007 merged commit 32cf2b3 into Layr-Labs:master Oct 27, 2026
4 of 9 checks passed
jonathan308 added a commit that referenced this pull request Oct 27, 2026
Brings in #1605 and #1606 (merged), #1566, #1591, #1602 and #1625.

Conflict resolved:
- docs/provider/troubleshooting.md: only the "Last updated" stamp
  conflicted; kept one stamp (2026-10-27). Both sides' text is kept.
@Gajesh2007 Gajesh2007 mentioned this pull request Oct 27, 2026
7 of 9 tasks
davidtai added a commit that referenced this pull request Oct 28, 2026
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>
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.

[bug] darkbloom switch reports every local model as missing when model_cache_directory is non-default (0.9.20)

2 participants