Module: Legion::Extensions::Llm::Mlx

Extended by:
AutoRegistration, Logging::Helper
Defined in:
lib/legion/extensions/llm/mlx.rb,
lib/legion/extensions/llm/mlx/version.rb,
lib/legion/extensions/llm/mlx/provider.rb,
lib/legion/extensions/llm/mlx/actors/fleet_worker.rb,
lib/legion/extensions/llm/mlx/runners/fleet_worker.rb,
lib/legion/extensions/llm/mlx/actors/discovery_refresh.rb

Overview

Mlx provider extension namespace.

Defined Under Namespace

Modules: Actor, Capabilities, CapabilityConfig, CapabilityResolution, HealthHelpers, Runners Classes: Provider

Constant Summary collapse

PROVIDER_FAMILY =
:mlx
VERSION =
'0.5.2'

Class Method Summary collapse

Class Method Details

.configured_instancesObject

Only instances the operator actually configured are claimable. The synthetic instances.default section (provider_settings nests the extension's own instance defaults there at boot) is skipped with a once-per-boot warn while it is still the unmodified extension default — an unconfigured phantom must never be auto-registered, and a localhost endpoint is never a fallback identity.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/legion/extensions/llm/mlx.rb', line 56

def self.configured_instances
  provider_cfg = Legion::Settings.dig(:extensions, :llm, :mlx) || {}
  instances = {}
  cfg_instances = provider_cfg[:instances]
  if cfg_instances.is_a?(Hash)
    cfg_instances.each do |name, config|
      normalized = normalize_instance_config(config)
      instances[name.to_sym] = normalized
    end
  end
  instances
end

.default_settingsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/legion/extensions/llm/mlx.rb', line 18

def self.default_settings
  ::Legion::Extensions::Llm.provider_settings(
    family: PROVIDER_FAMILY,
    instance: {
      endpoint: 'http://localhost:8000',
      tier: :local,
      transport: :http,
      credentials: { api_key: nil },
      usage: { inference: true, embedding: true, image: false },
      limits: { concurrency: 1 },
      fleet: {
        enabled: false,
        respond_to_requests: false,
        capabilities: %i[chat stream_chat embed]
      }
    }
  )
end

.discover_instancesObject

Single source of truth for MLX instance discovery. The SSOT discovery actor and the fleet responder both read this: only operator-configured instances. No port-scanning, no fabricated instances, no tier override.



45
46
47
# File 'lib/legion/extensions/llm/mlx.rb', line 45

def self.discover_instances
  configured_instances
end

.normalized_synthetic_default_instanceObject



83
84
85
86
87
# File 'lib/legion/extensions/llm/mlx.rb', line 83

def self.normalized_synthetic_default_instance
  @normalized_synthetic_default_instance ||= normalize_instance_config(
    default_settings.dig(:instances, :default) || {}
  )
end

.provider_classObject



37
38
39
# File 'lib/legion/extensions/llm/mlx.rb', line 37

def self.provider_class
  Provider
end

.unconfigured_default?(name:, normalized:) ⇒ Boolean

The synthetic default is the extension's OWN registered instance defaults (endpoint http://localhost:8000 + fleet/limits blocks), deep-merged into instances.default by provider_settings. It is "configured" only when the operator changed something — a configured 'default' passes the provider layer and reaches the claim path (v2 parity: 'default' is a plain instance label). ONE predicate, TWO consumers: the actor's claim path (tick_refresh iterates configured_instances into claim_and_activate_instance) and the fleet responder (discover_instances → configured_instances) both reach it through this single filter point — no drift.

Returns:

  • (Boolean)


79
80
81
# File 'lib/legion/extensions/llm/mlx.rb', line 79

def self.unconfigured_default?(name:, normalized:)
  name.to_sym == :default && normalized == normalized_synthetic_default_instance
end