Class: Legion::Extensions::Agentic::Executive::Control::Helpers::ControlSignal

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb

Constant Summary

Constants included from Constants

Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::ADAPTATION_ALPHA, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::AUTOMATIC_THRESHOLD, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::CONFLICT_BOOST, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::CONTROLLED_THRESHOLD, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::CONTROL_MODES, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::DEFAULT_EFFORT, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::EFFORT_CEILING, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::EFFORT_DECAY, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::EFFORT_FLOOR, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::EFFORT_LABELS, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::EFFORT_RECOVERY, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::ERROR_BOOST, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::GOAL_STATES, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::MAX_GOALS, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::MAX_HISTORY, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::MAX_POLICIES, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::NOVELTY_BOOST, Legion::Extensions::Agentic::Executive::Control::Helpers::Constants::OVERRIDE_THRESHOLD

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeControlSignal

Returns a new instance of ControlSignal.



15
16
17
18
19
20
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 15

def initialize
  @effort_level = DEFAULT_EFFORT
  @conflict_detected = false
  @error_detected = false
  @novelty_detected = false
end

Instance Attribute Details

#conflict_detectedObject (readonly)

Returns the value of attribute conflict_detected.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 12

def conflict_detected
  @conflict_detected
end

#effort_levelObject (readonly)

Returns the value of attribute effort_level.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 12

def effort_level
  @effort_level
end

#error_detectedObject (readonly)

Returns the value of attribute error_detected.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 12

def error_detected
  @error_detected
end

#novelty_detectedObject (readonly)

Returns the value of attribute novelty_detected.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 12

def novelty_detected
  @novelty_detected
end

Instance Method Details

#decayObject



55
56
57
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 55

def decay
  @effort_level = [@effort_level - EFFORT_DECAY, EFFORT_FLOOR].max
end

#detect_conflictObject



22
23
24
25
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 22

def detect_conflict
  @conflict_detected = true
  @effort_level = [@effort_level + CONFLICT_BOOST, EFFORT_CEILING].min
end

#detect_errorObject



27
28
29
30
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 27

def detect_error
  @error_detected = true
  @effort_level = [@effort_level + ERROR_BOOST, EFFORT_CEILING].min
end

#detect_noveltyObject



32
33
34
35
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 32

def detect_novelty
  @novelty_detected = true
  @effort_level = [@effort_level + NOVELTY_BOOST, EFFORT_CEILING].min
end

#effort_labelObject



50
51
52
53
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 50

def effort_label
  EFFORT_LABELS.each { |range, lbl| return lbl if range.cover?(@effort_level) }
  :automatic
end

#modeObject



43
44
45
46
47
48
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 43

def mode
  return :override if @effort_level >= OVERRIDE_THRESHOLD
  return :controlled if @effort_level >= CONTROLLED_THRESHOLD

  :automatic
end

#recover(amount: EFFORT_RECOVERY) ⇒ Object



59
60
61
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 59

def recover(amount: EFFORT_RECOVERY)
  @effort_level = [@effort_level + amount, EFFORT_CEILING].min
end

#reset_detectionsObject



37
38
39
40
41
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 37

def reset_detections
  @conflict_detected = false
  @error_detected = false
  @novelty_detected = false
end

#to_hObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/legion/extensions/agentic/executive/control/helpers/control_signal.rb', line 63

def to_h
  {
    effort_level:      @effort_level.round(4),
    mode:              mode,
    effort_label:      effort_label,
    conflict_detected: @conflict_detected,
    error_detected:    @error_detected,
    novelty_detected:  @novelty_detected
  }
end