Class: RuboCop::Cop::Legion::Llm::TaxonomyEnum
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Legion::Llm::TaxonomyEnum
- Defined in:
- lib/rubocop/cop/legion/llm/taxonomy_enum.rb
Overview
Validates lane field literals against the LegionIO taxonomy enums.
Flags :tier, :type, and :circuit_state literals that are not in
the known-valid sets, catching typos at lint time.
:tier and :circuit_state are domain-specific keys and are always
validated. :type is only validated when it appears in a hash that
also contains :tier or :circuit_state, since :type alone is too
common in non-taxonomy contexts.
Valid values (from Inventory::DEFAULT_PROVIDER_TIERS and the SSOT design):
tier: :local, :fleet, :cloud, :frontier, :direct
type: :inference, :embedding, :moderation, :rerank, :image
circuit_state: :closed, :open, :half_open
Constant Summary collapse
- VALID_TIERS =
%i[local fleet cloud frontier direct].freeze
- VALID_TYPES =
%i[inference embedding moderation rerank image].freeze
- VALID_CIRCUIT_STATES =
%i[closed open half_open].freeze
- TAXONOMY_KEYS =
%i[tier type circuit_state].freeze
- CONTEXT_KEYS =
%i[tier circuit_state].freeze
- MSG_TIER =
'Unknown tier `%<val>s`. Valid: %<valid>s.'- MSG_TYPE =
'Unknown type `%<val>s`. Valid: %<valid>s.'- MSG_CIRCUIT =
'Unknown circuit_state `%<val>s`. Valid: %<valid>s.'
Instance Method Summary collapse
Instance Method Details
#on_pair(node) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/rubocop/cop/legion/llm/taxonomy_enum.rb', line 47 def on_pair(node) key, value = node.children return unless key.sym_type? && value.sym_type? check_taxonomy(key.value, value, node) end |
#on_send(node) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/rubocop/cop/legion/llm/taxonomy_enum.rb', line 54 def on_send(node) return unless node.method_name == :[]= return unless node.arguments.size == 2 key_node, val_node = node.arguments return unless key_node.sym_type? && val_node.sym_type? check_taxonomy(key_node.value, val_node, node) end |