Module: Legion::LLM::Inventory::Discovery

Extended by:
Legion::Logging::Helper
Defined in:
lib/legion/llm/inventory/discovery.rb

Overview

Live capability/model facts over the inventory registry. Selection itself is owned by the SSOT router (Router.next_lane is the sole selection authority); Discovery answers two read-only questions against the same registry lanes the router reads — no state, no second selection domain.

Class Method Summary collapse

Class Method Details

.can_embed?Boolean

M4: SSOT :embed routing (Call::Embeddings → Router.next_lane via RequestRequirements(operation: :embed, required_capabilities: [:embedding])) is the SOLE selection authority for embeddings. can_embed? answers one capability FACT against the registry lanes — the same lanes the router reads: is there an embedding-type lane the router can select? (Live query — no boot-time detection state.)

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/legion/llm/inventory/discovery.rb', line 24

def can_embed?
  Legion::LLM::Inventory.snapshot.each_lane.any? do |lane|
    Legion::Extensions::Llm::Taxonomies.lane_type_for(operation: lane.operation) == :embedding
  end
end

.model_available?(model, provider: nil, instance: nil) ⇒ Boolean

Check whether a specific model is available from any registered provider. Reads the registry lanes — no discovery cache.

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/legion/llm/inventory/discovery.rb', line 32

def model_available?(model, provider: nil, instance: nil)
  psym = provider&.to_sym
  isym = instance&.to_sym
  Legion::LLM::Inventory.snapshot.each_lane.any? do |l|
    name_matches?(l.model, model.to_s) &&
      (psym.nil? || l.provider_family == psym) &&
      (isym.nil? || l.instance_id.to_s == isym.to_s)
  end
end

.model_size(_model) ⇒ Object

Return the size in bytes for a discovered model, or nil if unknown. After P3, size_bytes is not stored on lanes; always nil.



44
45
46
# File 'lib/legion/llm/inventory/discovery.rb', line 44

def model_size(_model, **)
  nil
end