Repository navigation
feat(provider): only discover/advertise coordinator-catalog models - #395
Gajesh2007 wants to merge 4 commits into
Conversation
Make the provider treat the coordinator model catalog as the single source of truth for which local weights can be discovered, advertised, served, or diagnosed. Non-catalog weights are invisible to the network and to the operator-facing CLI. - Fetch and cache the coordinator catalog at startup; fail closed if unavailable. - Filter all local model paths through the catalog before applying enabled_models/--model/--all. - Harden runtime prefetch and coordinator registration to drop non-catalog builds. - Update doctor, models catalog, status, benchmark, and docs. - Add Swift + Go tests for catalog filtering.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR introduces a server-side model catalog gate in Trust Boundaries Touched
Threat AssessmentT-034 — Provider runs modified code while advertising a trusted identityℹ️ Neutral on the core APNs code-identity chain; minor strengthening of the model-registration surface.
Security posture notes:
T-009 — Swift provider excluded from private-request routing due to missing Python flagsℹ️ Neutral — no change to the routing gate logic itself. The T-008 — Provider sends plaintext SSE chunks on encryption failureℹ️ Neutral — no change to the encryption/plaintext fallback path in T-010 — In-flight inference cancellation not propagated to inference engineℹ️ Neutral — no change to cancellation handling. T-011 — Provider operator reads X25519 private key from config fileℹ️ Neutral — New Attack Surface
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d9bff2629
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Fetch the coordinator catalog. A cached snapshot is used as a fallback | ||
| // so offline commands can still distinguish supported models. | ||
| let catalog = try? await fetchCatalogSnapshot(coordinatorURL: config.coordinator.url) |
There was a problem hiding this comment.
Fetch the catalog from the overridden coordinator
When darkbloom start --coordinator-url ... is used, the snapshot now fetches the catalog from config.coordinator.url before Start computes the override, while the launched daemon still connects to the overridden coordinator. In dev/staging or self-hosted runs with a different catalog, this new catalog gate validates against the wrong coordinator, so override-only models can be dropped or unrelated config/prod models can be advertised. Pass the effective coordinator URL into the catalog fetch for start modes that support an override.
Useful? React with 👍 / 👎.
| if !effectiveOverrides.isEmpty { | ||
| selectedModels = advertisedModels(from: snapshot.models, config: config, catalog: snapshot.catalog, modelOverrides: effectiveOverrides) |
There was a problem hiding this comment.
Preserve explicit model filters after catalog drops
If a launchd plist or explicit --model list contains only models that are no longer in the catalog, effectiveOverrides becomes empty and this condition falls through to the default advertisedModels(...) path. In that scenario the provider can start serving every enabled/downloaded catalog model instead of the operator's pinned selection, broadening the advertised inventory after a retirement or typo. Keep the branch keyed on the original model list and let an empty filtered override set produce no selected models.
Useful? React with 👍 / 👎.
| if let catalog = loopConfig.catalog { | ||
| let catalogIDs = Set(catalog.models.map(\.id)) | ||
| guard catalogIDs.contains(modelId) else { |
There was a problem hiding this comment.
Don't gate verified prefetches on a stale catalog
When an alias is repointed or a new desired build is promoted while a provider is already connected, the coordinator fans out fresh desired_models and CatalogModelPrefetcher resolves that build against the live coordinator catalog, but this guard checks only the startup snapshot. Providers that successfully download and verify a newly-added build will refuse to advertise it until they restart, so live model rollouts cannot converge on the existing fleet.
Useful? React with 👍 / 👎.
| // The provider is expected to filter its advertised set client-side, | ||
| // but this is the server-side backstop that keeps unsupported weights | ||
| // out of provider counts and routing state. | ||
| if filtered, dropped := s.filterRegistrationModels(regMsg.Models); len(dropped) > 0 { |
There was a problem hiding this comment.
Keep retired alias builds long enough to resync
For a provider that was offline through the end of an alias rollout, its only advertised build can be an alias retired_builds member that is intentionally no longer in the active catalog; DesiredModelsForProvider has explicit retired-lineage handling so that returning provider can be sent the current desired build. Dropping the retired model before registration erases that lineage, so the coordinator sends no desired_models and the provider stays stranded instead of self-updating.
Useful? React with 👍 / 👎.
| config: ProviderConfig, | ||
| hardware: HardwareInfo | ||
| ) async throws { | ||
| guard snapshot.catalog != nil else { |
There was a problem hiding this comment.
Allow direct mode to start without a catalog
--local is documented as a coordinator-less local server and even supports trusted/airgapped use, but this new guard makes it fail on a fresh offline machine unless a coordinator catalog was fetched or cached first. A user with already-downloaded local weights can no longer start the direct OpenAI endpoint when the coordinator is unreachable, even though that mode does not connect to the coordinator. Let direct mode fall back to local model selection instead of requiring a live/catalog cache.
Useful? React with 👍 / 👎.
- Fetch catalog from the effective coordinator URL so --coordinator-url overrides apply to both the catalog source and the connect target. - Preserve explicit --model intent when all pinned IDs are filtered out (launchd/foreground path no longer falls through to --all/default). - Remove stale startup-catalog gate from applyVerifiedPrefetch; live alias repoints and new build rollouts are validated by the prefetcher and the coordinator's models_update gate. - Keep retired alias builds at coordinator registration so offline-through- retirement providers can still receive desired_models updates. - Allow --local mode to start without a catalog, using local model selection for offline/airgapped use. - Add tests for retired-alias registration and localAdvertisedModels.
|
Addressed the Codex review feedback in commit
Added tests for retired-alias registration preservation and |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b8d727a77
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let alternatives = allModels.map { | ||
| // Diagnose only models the coordinator currently advertises. Local | ||
| // weights that are not in the catalog are never served. | ||
| let supportedModels = catalogFilteredModels(snapshot.models, catalog: snapshot.catalog) |
There was a problem hiding this comment.
Diagnose model fit from the unfiltered local scan
This now feeds the doctor fit check from snapshot.models, but that snapshot is built with ModelScanner.scanModels, which filters out any downloaded model whose estimatedMemoryGb exceeds available memory. When an operator has configured or loaded a catalog-supported model that is too large for the Mac, the target is absent from supportedModels, so doctor falls back to another model or emits no fit warning instead of flagging the exact model that will fail to load. Use the unfiltered local scan and then apply the catalog filter so too-large supported models can still be diagnosed.
Useful? React with 👍 / 👎.
| /// unavailable so the caller's existing "no models" guard still fires. | ||
| private func catalogFilteredOverrides(_ overrides: [String], catalog: CatalogSnapshot?) -> [String] { | ||
| guard let catalog else { return overrides } | ||
| let catalogIDs = Set(catalog.models.map(\.id)) |
There was a problem hiding this comment.
Preserve alias lineage in foreground model filters
Fresh evidence: although the server-side registration filter now keeps alias lineage, this new foreground filter still allows only catalog.models IDs and ignores catalog.aliases.previous_build / retired_builds. A provider whose launchd plist contains only the previous or retired build after being offline through an alias rollout will drop that --model, hit the empty-selection guard, and exit before it can register and receive the coordinator's desired_models update. Include alias lineage builds in the allowed set for stale plist filtering.
Useful? React with 👍 / 👎.
| let models = advertisedModels( | ||
| from: snapshot.models, | ||
| config: snapshot.config, | ||
| catalog: snapshot.catalog, | ||
| includeDisabled: all |
There was a problem hiding this comment.
Honor --all when listing local models
For darkbloom models list --all, this still passes the coordinator catalog into advertisedModels, so --all only bypasses enabled_models and continues to hide any downloaded weights that are off-catalog or when the catalog/cache is unavailable. The command is documented as listing local cached models, and operators need this path to inventory/remove unsupported downloads; use the unfiltered local scan for --all or report unsupported models separately instead of dropping them.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| let models = advertisedModels(from: snapshot.models, config: snapshot.config) | ||
| let models = advertisedModels(from: snapshot.models, config: snapshot.config, catalog: snapshot.catalog) |
There was a problem hiding this comment.
Let local benchmarks run without a catalog
When the coordinator catalog cannot be fetched and no cache exists, advertisedModels returns an empty list, so darkbloom benchmark --model <downloaded-id> fails before it ever loads the local model. Benchmarking is a local operation that only needs downloaded weights and hardware info, so tying it to catalog reachability breaks offline performance experiments and benchmarking of local-only weights; fall back to the local model selection path here rather than the network-advertising filter.
Useful? React with 👍 / 👎.
| } catch { | ||
| // Fall back to the on-disk cache so offline/briefly-unreachable | ||
| // commands still see the last known catalog. | ||
| return CatalogCache.read() |
There was a problem hiding this comment.
Scope cached catalogs to the coordinator URL
Fresh evidence: the live fetch now uses the overridden coordinator, but failures fall back to one global ~/.cache/darkbloom/catalog.json written by whichever coordinator was contacted last. When switching between prod, staging, or self-hosted coordinators, a transient catalog fetch failure can validate startup/status against another coordinator's catalog, dropping override-only models or accepting stale IDs; key the cache by coordinator base URL or ignore it when it was populated from a different coordinator.
Useful? React with 👍 / 👎.
|
Found 8 test failures on Blacksmith runners: Failures
|
- RuntimeSnapshot now carries both memory-filtered (loadable) and unfiltered local model scans; doctor diagnoses from the unfiltered set so too-large supported models are still flagged. - Preserve alias previous/retired lineage in foreground --model filters and validation by using a new catalogAllowedIDs() helper. - darkbloom models list --all now inventories every discovered local weight, bypassing the coordinator catalog filter. - darkbloom benchmark falls back to local model selection when no catalog is available, so offline/local-only benchmarking works. - Catalog cache is now scoped by coordinator base URL; switching coordinators no longer risks cross-polluting offline fallback state. - Add tests for catalogAllowedIDs and coordinator-scoped cache paths.
|
Addressed the second round of Codex feedback in commit
Added tests for |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c04679c9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await runUpdateBannerIfEnabled() | ||
|
|
||
| let snapshot = try loadRuntimeSnapshot(configOptions: configOptions) | ||
| let snapshot = try await loadRuntimeSnapshot(configOptions: configOptions) |
There was a problem hiding this comment.
Use the override when loading the doctor catalog
When running darkbloom doctor --coordinator <staging-or-self-hosted>, this snapshot load now fetches and caches the coordinator model catalog, but it still uses the config coordinator instead of the --coordinator override while the later network checks use the override. That makes doctor diagnose model catalog availability/fit against prod or the cached config coordinator, producing false “catalog unavailable” or wrong supported-model results for the coordinator the operator is actually checking; pass coordinatorURLOverride: coordinator here.
Useful? React with 👍 / 👎.
| if effectiveOverrides.isEmpty { | ||
| selectedModels = [] |
There was a problem hiding this comment.
Validate daemon selections before installing launchd
When a user runs regular darkbloom start --model <non-catalog-id> (or --all on a cache with no catalog-supported models), the parent path still writes the raw IDs into the launchd plist and prints “Provider started”; only the foreground child reaches this new empty-selection branch and exits immediately. Filter/validate the selected IDs in launchDaemon before LaunchAgent.installAndStart so the command fails synchronously or installs only servable catalog IDs.
Useful? React with 👍 / 👎.
- DoctorCommand now passes --coordinator override into loadRuntimeSnapshot so the catalog is fetched/cached from the same coordinator used for diagnostics. - launchDaemon validates selections before installing the launchd plist: explicit --model selections are checked against catalogAllowedIDs, and --all is resolved to the actual catalog-supported model set (failing early if no catalog or no supported models are available). Build + targeted Swift tests pass; coordinator go test ./... passes.
|
Addressed the third round of Codex feedback in commit
Coordinator |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85e5190b78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| mutating func run() async throws { | ||
| let snapshot = try loadRuntimeSnapshot(configOptions: configOptions) | ||
| let snapshot = try await loadRuntimeSnapshot(configOptions: configOptions) |
There was a problem hiding this comment.
Use the verify override when loading the catalog
When darkbloom verify --coordinator <staging-or-self-hosted> is used, the coordinator checks below use the override but this snapshot still fetches the model catalog from the configured coordinator. That makes the strict doctor-style local checks validate traffic readiness against the wrong catalog/cache, so a valid staging/self-hosted setup can warn or exit non-zero because prod/config catalog data is missing or different; pass coordinatorURLOverride: coordinator here as doctor now does.
Useful? React with 👍 / 👎.
The library pull request branch now holds a merge of library main 7f196e02c2, so the pin moves from 6d2c82a0e4 to that merge. The merge adds library #395 (nullable tool arguments), #302 (the Qwen3.5 MTP prefill projects only the last prompt position), #364 (the Gemma 4 dispatch change), #365 (reuse of compiled Gemma 4 feed-forward graphs) and #366 (greedy batches skip unused sampler metadata). dev does not have them yet. No provider source changes. The pin stays provisional until the library pull request merges. Co-Authored-By: Claude <noreply@anthropic.com>
libs/mlx-swift-lm moves from fd48d47f to 093563be, the merge commit of mlx-swift-lm #367 on main. It holds every 0.10.12 SDK PR, each merged with a merge commit: #372, #301, #395 (nullable tool arguments), #302, #364, #365, #366 and #367. libs/mlx-swift and libs/mlx are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libs/mlx-swift-lm moves from 04940f55 to 093563be, the merge commit of mlx-swift-lm #367 on main. It holds every 0.10.12 SDK PR, each merged with a merge commit: #372, #301, #395 (nullable tool arguments), #302, #364, #365, #366 and #367. libs/mlx-swift and libs/mlx are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libs/mlx-swift-lm moves from 1aace467 to 093563be, the merge commit of mlx-swift-lm #367 on main. It holds every 0.10.12 SDK PR, each merged with a merge commit: #372, #301, #395 (nullable tool arguments), #302, #364, #365, #366 and #367. libs/mlx-swift and libs/mlx are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libs/mlx-swift-lm moves from f6b9ac22 to 093563be, the merge commit of mlx-swift-lm #367 on main. It holds every 0.10.12 SDK PR, each merged with a merge commit: #372, #301, #395 (nullable tool arguments), #302, #364, #365, #366 and #367. libs/mlx-swift and libs/mlx are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libs/mlx-swift-lm moves from 51da1368 to 093563be, the merge commit of mlx-swift-lm #367 on main. It holds every 0.10.12 SDK PR, each merged with a merge commit: #372, #301, #395 (nullable tool arguments), #302, #364, #365, #366 and #367. libs/mlx-swift and libs/mlx are unchanged. changelog.d/qwen35-mtp-prefill-last-row.md: mlx-swift-lm #302 (Qwen 3.5 MTP prompts project only their last position) rides this pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Summary
Make the Darkbloom provider treat the coordinator model catalog as the single source of truth for which local weights can be discovered, advertised, served, or diagnosed. Non-catalog weights are invisible to the network and to the operator-facing CLI.
Before / After
Before: any local MLX weight directory could be advertised
sequenceDiagram participant U as Operator participant P as darkbloom provider participant C as Coordinator participant R as Registry/Scheduler U->>P: darkbloom start --all P->>P: scan ~/.cache/lm-studio/Models P->>P: scan ~/.lmstudio/models P->>C: register with every discovered model C->>R: expose unsupported IDs as available capacity R->>C: route consumer requests to unsupported weightsAfter: only coordinator-catalog models are discovered or advertised
sequenceDiagram participant U as Operator participant P as darkbloom provider participant C as Coordinator participant R as Registry/Scheduler U->>P: darkbloom start --all P->>C: GET /v1/models/catalog C-->>P: supported model IDs P->>P: scan local directories P->>P: filter discovered models against catalog P->>C: register only catalog-matching models C->>R: expose only supported IDs as available capacity R->>C: route consumer requests to supported weights onlyChanges
Provider (Swift)
loadRuntimeSnapshotfetchesGET /v1/models/catalogat startup and caches it to~/.cache/darkbloom/catalog.json. Offline commands fall back to the cache; if none exists, the catalog is treated as empty (fail closed).catalogFilteredModels()and updatedadvertisedModels()filter every local model through the coordinator catalog before applyingenabled_modelsor--model.darkbloom start --allnow means "all downloaded models that are in the catalog."darkbloom start --model <non-catalog-id>fails with a clear error for explicit user invocations; the launchd--foregroundpath filters stale plist flags and logs warnings instead of refusing to start.darkbloom doctordiagnoses only catalog models and warns when the catalog cannot be fetched.darkbloom models catalogno longer shows a "Local only" section; off-catalog weights get a one-line "will not be served" note.ProviderLoop.applyVerifiedPrefetchrefuses to advertise a prefetched build that is not in the catalog.ProviderLoopConfigcarries the startup catalog snapshot.Coordinator (Go)
msg.Modelsto catalog-known IDs and logs any dropped non-catalog models as a defense-in-depth backstop.Tests & docs
CatalogFilterTests.swiftcoveringcatalogFilteredModelsandadvertisedModels.TestProviderRegistrationFiltersNonCatalogModels.docs/provider/cli-reference.mdanddocs/provider/quickstart.md.Verification
cd coordinator && go test ./... -count=1✅cd provider-swift && swift build✅cd provider-swift && swift test --filter "CLIDispatchTests|CatalogFilterTests|ModelPrefetchCoordinatorTests"✅swift testexits non-zero due to a pre-existingMLX error: Failed to load the default metallibcrash in a live-model test, unrelated to these changes.Closes the feedback where providers "actively try to use" models that the coordinator does not support.