Class: Legion::LLM::Router::SettingsSnapshot
- Inherits:
-
Object
- Object
- Legion::LLM::Router::SettingsSnapshot
- Includes:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/router/settings_snapshot.rb
Overview
Immutable, validated snapshot of all selection-relevant settings for one reload generation. Built once by SettingsState.install!/reload! and consumed read-only by every selection call. Runtime selection never reaches back into Legion::Settings.
Instance Attribute Summary collapse
-
#affinity_strength_bps ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#allow_body_routing_hints ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#auto_routing_model_alias_metadata ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#auto_routing_model_aliases ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#body_model_hint_blacklist ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#body_model_hint_whitelist ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#context_headroom_ppm ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#generation ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#input_framing_overhead_tokens ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#maximum_attempts ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#routing_too_early_retry_after ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
-
#tier_weights ⇒ Object
readonly
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #.
Class Method Summary collapse
-
.build(generation:, llm_settings:, extension_settings:) ⇒ Object
------------------------------------------------------------------ # Public factory # ------------------------------------------------------------------ #.
Instance Method Summary collapse
-
#capability_override_for(provider_family:, instance_id:, capability:, model:) ⇒ Object
The operator's cascaded enable_
routing override for the exact instance (config name), resolved through the lex-llm 3-level cascade (provider -> instance -> model, most-specific-first). -
#model_policy_for(offering:) ⇒ Object
Returns { whitelist: Array
, blacklist: Array } using the §9.5 specificity cascade: exact provider+instance → provider → global. -
#preferred_context_range_for(lane:) ⇒ Object
Returns { min: Integer_or_nil, max: Integer_or_nil } or nil when no preferred range is configured.
Instance Attribute Details
#affinity_strength_bps ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def affinity_strength_bps @affinity_strength_bps end |
#allow_body_routing_hints ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def allow_body_routing_hints @allow_body_routing_hints end |
#auto_routing_model_alias_metadata ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def @auto_routing_model_alias_metadata end |
#auto_routing_model_aliases ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def auto_routing_model_aliases @auto_routing_model_aliases end |
#body_model_hint_blacklist ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def body_model_hint_blacklist @body_model_hint_blacklist end |
#body_model_hint_whitelist ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def body_model_hint_whitelist @body_model_hint_whitelist end |
#context_headroom_ppm ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def context_headroom_ppm @context_headroom_ppm end |
#generation ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def generation @generation end |
#input_framing_overhead_tokens ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def input_framing_overhead_tokens @input_framing_overhead_tokens end |
#maximum_attempts ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def maximum_attempts @maximum_attempts end |
#routing_too_early_retry_after ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def routing_too_early_retry_after @routing_too_early_retry_after end |
#tier_weights ⇒ Object (readonly)
------------------------------------------------------------------ # Readers # ------------------------------------------------------------------ #
40 41 42 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 40 def tier_weights @tier_weights end |
Class Method Details
.build(generation:, llm_settings:, extension_settings:) ⇒ Object
------------------------------------------------------------------ # Public factory # ------------------------------------------------------------------ #
28 29 30 31 32 33 34 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 28 def self.build(generation:, llm_settings:, extension_settings:) snap = new(generation: generation, llm_settings: llm_settings, extension_settings: extension_settings) snap.freeze snap end |
Instance Method Details
#capability_override_for(provider_family:, instance_id:, capability:, model:) ⇒ Object
The operator's cascaded enable_
74 75 76 77 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 74 def capability_override_for(provider_family:, instance_id:, capability:, model:) cascade_value(provider_family: provider_family, instance_id: instance_id, key: :"enable_#{capability}", model: model) end |
#model_policy_for(offering:) ⇒ Object
Returns { whitelist: Array
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 82 def model_policy_for(offering:) ik = offering.instance_key pf = ik.provider_family # Symbol iid = ik.instance_id # String prov = ext_llm_provider(pf) inst = ext_llm_instance(prov, iid) wl = first_existing_policy(inst, prov, :model_whitelist) bl = first_existing_policy(inst, prov, :model_blacklist) { whitelist: Array(wl).freeze, blacklist: Array(bl).freeze }.freeze end |
#preferred_context_range_for(lane:) ⇒ Object
Returns { min: Integer_or_nil, max: Integer_or_nil } or nil when no preferred range is configured. Resolved through the lex-llm 3-level cascade (provider -> instance -> model, most-specific-first) keyed by the config name, so a provider- or model-level leg can supply either bound.
58 59 60 61 62 63 64 65 66 |
# File 'lib/legion/llm/router/settings_snapshot.rb', line 58 def preferred_context_range_for(lane:) min_v = cascade_value(provider_family: lane.provider_family, instance_id: lane.instance_id, key: :preferred_min_context_tokens, model: lane.model) max_v = cascade_value(provider_family: lane.provider_family, instance_id: lane.instance_id, key: :preferred_max_context_tokens, model: lane.model) return nil unless min_v || max_v { min: min_v, max: max_v }.freeze end |