Module: Legion::Extensions::Synapse::Helpers::Confidence
- Defined in:
- lib/legion/extensions/synapse/helpers/confidence.rb
Constant Summary collapse
- VALID_STATUSES =
%w[active observing dampened].freeze
- EVALUABLE_STATUSES =
%w[active observing].freeze
- VALID_ORIGINS =
%w[explicit emergent seeded].freeze
- VALID_OUTCOMES =
%w[success failed].freeze
- STARTING_SCORES =
{ explicit: 0.7, emergent: 0.3, seeded: 0.5 }.freeze
- ADJUSTMENTS =
{ success: 0.02, failure: -0.05, validation_failure: -0.03, consecutive_bonus: 0.05 }.freeze
- DECAY_RATE =
0.998- CONSECUTIVE_BONUS_THRESHOLD =
50- AUTONOMY_RANGES =
{ observe: 0.0..0.3, filter: 0.3..0.6, transform: 0.6..0.8, autonomous: 0.8..1.0 }.freeze
Class Method Summary collapse
- .adjust(confidence, event, consecutive_successes: 0) ⇒ Object
- .autonomy_mode(confidence) ⇒ Object
- .can_filter?(confidence) ⇒ Boolean
- .can_self_modify?(confidence) ⇒ Boolean
- .can_transform?(confidence) ⇒ Boolean
- .decay(confidence, hours: 1) ⇒ Object
- .starting_score(origin) ⇒ Object
Class Method Details
.adjust(confidence, event, consecutive_successes: 0) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 35 def adjust(confidence, event, consecutive_successes: 0) delta = ADJUSTMENTS.fetch(event, 0) result = confidence + delta result += ADJUSTMENTS[:consecutive_bonus] if event == :success && consecutive_successes > CONSECUTIVE_BONUS_THRESHOLD new_confidence = clamp(result) Legion::Events.emit('synapse.confidence_update', delta: delta, event: event, new_confidence: new_confidence) if defined?(Legion::Events) new_confidence end |
.autonomy_mode(confidence) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 48 def autonomy_mode(confidence) AUTONOMY_RANGES.each do |mode, range| return mode if range.include?(confidence) end :observe end |
.can_filter?(confidence) ⇒ Boolean
55 56 57 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 55 def can_filter?(confidence) confidence >= 0.3 end |
.can_self_modify?(confidence) ⇒ Boolean
63 64 65 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 63 def can_self_modify?(confidence) confidence >= 0.8 end |
.can_transform?(confidence) ⇒ Boolean
59 60 61 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 59 def can_transform?(confidence) confidence >= 0.6 end |
.decay(confidence, hours: 1) ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 44 def decay(confidence, hours: 1) clamp(confidence * (DECAY_RATE**hours)) end |
.starting_score(origin) ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/synapse/helpers/confidence.rb', line 31 def starting_score(origin) STARTING_SCORES.fetch(origin.to_sym, 0.5) end |