Module: Legion::LLM::Router::CandidateEvaluator

Extended by:
Legion::Logging::Helper
Defined in:
lib/legion/llm/router/candidate_evaluator.rb

Overview

SSOT v3 §9.7 — hard-filter and evidence evaluator.

Iterates every offering in the captured snapshot, resolves the exact instance and lane for supported operations, evaluates all ten axes in canonical order, and returns an immutable EvaluationSet. Performs no winner selection and no early return.

Offering iteration (not lane iteration) is the authoritative source: lanes exist only for supported operations, so operation unknown/ unsupported diagnosis must start from offerings.

Also iterates snapshot.each_publication_status to populate EvaluationSet#publication_statuses, including initializing scopes that have no active offering. Those status diagnostics are inputs to RejectionDiagnostics but are not CandidateEvaluation objects.

Class Method Summary collapse

Class Method Details

.call(requirements:, exclusions:, snapshot:, settings_snapshot:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/llm/router/candidate_evaluator.rb', line 30

def call(requirements:, exclusions:, snapshot:, settings_snapshot:)
  excl_list = Array(exclusions).freeze
  candidates = []

  snapshot.each_offering do |offering|
    candidates << evaluate_offering(
      offering:          offering,
      requirements:      requirements,
      exclusions:        excl_list,
      snapshot:          snapshot,
      settings_snapshot: settings_snapshot
    )
  end

  publication_statuses = []
  snapshot.each_publication_status { |ps| publication_statuses << ps }

  log.debug('[llm][candidate_evaluator] action=evaluated ' \
            "candidates=#{candidates.size} " \
            "pub_statuses=#{publication_statuses.size} " \
            "generation=#{snapshot.generation}")

  EvaluationSet.new(
    candidates:           candidates,
    publication_statuses: publication_statuses,
    inventory_generation: snapshot.generation
  )
end