Class: Assistant::TechnicalSupport::CaseCandidateSelector

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/assistant/technical_support/case_candidate_selector.rb

Overview

Selects a small, narrative-rich and semantically diverse case sample from
the existing Technical Support search index. Selection is read-only; a
later CaseEventStream audit determines whether every linked source is
actually available for replay.

Defined Under Namespace

Classes: Result, Selection

Constant Summary collapse

DEFAULT_LIMIT =

Default number of cases to select.

10
MAX_LIMIT =

Hard ceiling on the number of cases returned.

50
PREFILTER_MULTIPLIER =

How many candidates to keep per requested case when building the prefilter pool.

12
MIN_PREFILTER_SIZE =

Minimum size of the prefilter pool regardless of the requested limit.

60
SEEDED_PRODUCT_FAMILIES =

Number of top product families guaranteed a seed slot in the result set.

3
MAX_FAMILY_SHARE =

Largest share of the final selection any single family may occupy.

0.4
QUALITY_WEIGHT =

Weight given to case quality in the combined selection score.

0.65
DIVERSITY_WEIGHT =

Weight given to semantic diversity in the combined selection score.

0.35
UNCLASSIFIED_FAMILY =

Fallback label for candidates with no identifiable product family.

'unclassified'

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callResult

Returns selected case IDs and auditable corpus counts.

Returns:

  • (Result)

    selected case IDs and auditable corpus counts



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/services/assistant/technical_support/case_candidate_selector.rb', line 92

def call
  requested_limit = limit.to_i.clamp(1, MAX_LIMIT)
  corpus = candidate_query.call(since:)
  pool = prefilter(corpus.candidates, requested_limit)
  selected = select_candidates(
    pool,
    requested_limit,
    balance_limit: resolved_family_balance_limit(requested_limit)
  )

  Result.new(
    since:,
    corpus_size: corpus.corpus_size,
    resolved_size: corpus.resolved_size,
    narrative_ready_size: corpus.narrative_ready_size,
    search_index_ready_size: corpus.search_index_ready_size,
    selections: selected
  )
end