Class: Legion::LLM::Routing::CandidateEvaluation

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/llm/routing/evaluation.rb

Overview

Immutable per-lane evaluation axes (SSOT v4 ยง7.6). One CandidateEvaluation is produced for every lane in the captured snapshot. It records the outcome of each hard/soft axis without selecting a winner. ready? is the single readiness predicate consumed by the Ranker; unknown is never ready.

Constant Summary collapse

AXES =
{
  operation:      %i[supported unsupported unknown],
  pin:            %i[match mismatch authority_unknown],
  policy:         %i[allowed denied],
  capability:     %i[supported unsupported unknown],
  context:        %i[fits rejected unknown not_applicable],
  dimension:      %i[match rejected unknown not_applicable],
  availability:   %i[available unavailable unknown],
  exclusion:      %i[clear excluded],
  fleet_contract: %i[supported legacy unknown not_applicable],
  weight:         %i[enabled disabled]
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lane:, operation_state:, pin_state:, policy_state:, capability_state:, context_state:, dimension_state:, availability_state:, exclusion_state:, fleet_contract_state:, weight_state:, instance: nil, publication_status: nil, weight_inputs: nil, reasons: []) ⇒ CandidateEvaluation

Returns a new instance of CandidateEvaluation.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/legion/llm/routing/evaluation.rb', line 29

def initialize(lane:, operation_state:, pin_state:, policy_state:, capability_state:,
               context_state:, dimension_state:, availability_state:, exclusion_state:,
               fleet_contract_state:, weight_state:, instance: nil,
               publication_status: nil, weight_inputs: nil, reasons: [], **)
  @lane = lane
  @instance = instance
  @publication_status = publication_status
  @operation_state = validate!(:operation, operation_state)
  @pin_state = validate!(:pin, pin_state)
  @policy_state = validate!(:policy, policy_state)
  @capability_state = validate!(:capability, capability_state)
  @context_state = validate!(:context, context_state)
  @dimension_state = validate!(:dimension, dimension_state)
  @availability_state = validate!(:availability, availability_state)
  @exclusion_state = validate!(:exclusion, exclusion_state)
  @fleet_contract_state = validate!(:fleet_contract, fleet_contract_state)
  @weight_state = validate!(:weight, weight_state)
  @weight_inputs = weight_inputs&.freeze
  @reasons = reasons.freeze
  freeze
end

Instance Attribute Details

#availability_stateObject (readonly)

Returns the value of attribute availability_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def availability_state
  @availability_state
end

#capability_stateObject (readonly)

Returns the value of attribute capability_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def capability_state
  @capability_state
end

#context_stateObject (readonly)

Returns the value of attribute context_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def context_state
  @context_state
end

#dimension_stateObject (readonly)

Returns the value of attribute dimension_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def dimension_state
  @dimension_state
end

#exclusion_stateObject (readonly)

Returns the value of attribute exclusion_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def exclusion_state
  @exclusion_state
end

#fleet_contract_stateObject (readonly)

Returns the value of attribute fleet_contract_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def fleet_contract_state
  @fleet_contract_state
end

#instanceObject (readonly)

Returns the value of attribute instance.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def instance
  @instance
end

#laneObject (readonly)

Returns the value of attribute lane.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def lane
  @lane
end

#operation_stateObject (readonly)

Returns the value of attribute operation_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def operation_state
  @operation_state
end

#pin_stateObject (readonly)

Returns the value of attribute pin_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def pin_state
  @pin_state
end

#policy_stateObject (readonly)

Returns the value of attribute policy_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def policy_state
  @policy_state
end

#publication_statusObject (readonly)

Returns the value of attribute publication_status.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def publication_status
  @publication_status
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def reasons
  @reasons
end

#weight_inputsObject (readonly)

Returns the value of attribute weight_inputs.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def weight_inputs
  @weight_inputs
end

#weight_stateObject (readonly)

Returns the value of attribute weight_state.



24
25
26
# File 'lib/legion/llm/routing/evaluation.rb', line 24

def weight_state
  @weight_state
end

Instance Method Details

#ready?Boolean

Ready only when an executable lane exists, every applicable hard axis conclusively passes, the exact instance is available, and configured weight is enabled. Any unknown/mismatch/denied/excluded/unavailable fails.

Returns:

  • (Boolean)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/legion/llm/routing/evaluation.rb', line 54

def ready?(**)
  return false if @lane.nil?
  return false unless @operation_state == :supported
  return false unless @pin_state == :match
  return false unless @policy_state == :allowed
  return false unless @capability_state == :supported
  return false unless %i[fits not_applicable].include?(@context_state)
  return false unless %i[match not_applicable].include?(@dimension_state)
  return false unless @availability_state == :available
  return false unless @exclusion_state == :clear
  return false unless %i[supported not_applicable].include?(@fleet_contract_state)
  return false unless @weight_state == :enabled

  true
end