Module: Legion::Apollo::Helpers::Confidence

Extended by:
Logging::Helper
Defined in:
lib/legion/apollo/helpers/confidence.rb

Overview

Confidence constants and predicate helpers for Apollo knowledge entries. DB-dependent methods live in lex-apollo; only pure-function logic here.

Constant Summary collapse

INITIAL_CONFIDENCE =
0.5
CORROBORATION_BOOST =
0.15
CONTRADICTION_PENALTY =
0.20
DECAY_RATE =
0.005
WRITE_GATE_THRESHOLD =
0.3
HIGH_CONFIDENCE =
0.8
ARCHIVE_THRESHOLD =
0.1
INITIAL_INFERENCE_CONFIDENCE =
0.35
STATUSES =
%i[pending confirmed disputed deprecated archived].freeze
CONTENT_TYPES =
%i[
  fact observation hypothesis procedure opinion
  question answer summary analysis synthesis
].freeze

Class Method Summary collapse

Class Method Details

.above_write_gate?(confidence) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/legion/apollo/helpers/confidence.rb', line 39

def above_write_gate?(confidence)
  confidence.to_f >= WRITE_GATE_THRESHOLD
end

.apollo_setting(key, default) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/legion/apollo/helpers/confidence.rb', line 47

def apollo_setting(key, default)
  return default unless defined?(Legion::Settings) && !Legion::Settings[:apollo].nil?

  Legion::Settings[:apollo][key] || default
rescue StandardError => e
  handle_exception(e, level: :debug, operation: 'apollo.helpers.confidence.apollo_setting', key: key)
  default
end

.high_confidence?(confidence) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/legion/apollo/helpers/confidence.rb', line 43

def high_confidence?(confidence)
  confidence.to_f >= HIGH_CONFIDENCE
end

.valid_content_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/legion/apollo/helpers/confidence.rb', line 35

def valid_content_type?(type)
  CONTENT_TYPES.include?(type&.to_sym)
end

.valid_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/legion/apollo/helpers/confidence.rb', line 31

def valid_status?(status)
  STATUSES.include?(status&.to_sym)
end