Class: Legion::Extensions::Llm::Inventory::Identity::InstanceKey

Inherits:
Data
  • Object
show all
Defined in:
lib/legion/extensions/llm/inventory/identity.rb

Overview

A mandatory, immutable provider_family + instance_id pair. Provider family alone is never executable; two instances of the same provider are independent targets. See section 8.1.

instance_id is the operator's CONFIG NAME — the identity the router keys settings lookups (instances.) by. physical_id is an optional SECONDARY field carrying the physical/derived id (e.g. "host:port" or "host:port/ak:") preserved for dedup and diagnostics. It is NOT identity: it never participates in equality, hashing, or registry-scope identity, so two config names pointing at the same endpoint stay distinct instances.

There are NO reserved instance_id values (v2 parity): "default" is an ordinary operator label. Synthetic default-template protection lives provider-side (template-conditional discovery skip).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_family:, instance_id:, physical_id: nil) ⇒ InstanceKey

Returns a new instance of InstanceKey.



117
118
119
120
121
122
123
124
125
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 117

def initialize(provider_family:, instance_id:, physical_id: nil)
  family = Identity.normalize_text(value: provider_family, field: :provider_family).downcase
  raise Errors::ValidationError, 'provider_family must match /\A[a-z][a-z0-9_]*\z/' unless family.match?(/\A[a-z][a-z0-9_]*\z/)

  instance = Identity.normalize_text(value: instance_id, field: :instance_id)
  physical = physical_id.nil? ? nil : Identity.normalize_text(value: physical_id, field: :physical_id)

  super(provider_family: family.to_sym, instance_id: instance, physical_id: physical)
end

Instance Attribute Details

#instance_idObject (readonly)

Returns the value of attribute instance_id

Returns:

  • (Object)

    the current value of instance_id



116
117
118
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 116

def instance_id
  @instance_id
end

#physical_idObject (readonly)

Returns the value of attribute physical_id

Returns:

  • (Object)

    the current value of physical_id



116
117
118
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 116

def physical_id
  @physical_id
end

#provider_familyObject (readonly)

Returns the value of attribute provider_family

Returns:

  • (Object)

    the current value of provider_family



116
117
118
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 116

def provider_family
  @provider_family
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Identity is exactly (provider_family, instance_id). The secondary physical_id never affects equality, hashing, or registry-scope identity.



130
131
132
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 130

def ==(other)
  other.is_a?(self.class) && other.provider_family == provider_family && other.instance_id == instance_id
end

#hashObject



135
136
137
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 135

def hash
  [self.class, provider_family, instance_id].hash
end