Module: Legion::Extensions::Agentic::Homeostasis::Rhythm::Runners::CognitiveRhythm

Includes:
Helpers::Constants, Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb

Constant Summary

Constants included from Helpers::Constants

Helpers::Constants::AMPLITUDE_LABELS, Helpers::Constants::CIRCADIAN_PERIOD, Helpers::Constants::COGNITIVE_DIMENSIONS, Helpers::Constants::DEFAULT_PHASE_OFFSET, Helpers::Constants::MAX_AMPLITUDE, Helpers::Constants::MAX_HISTORY, Helpers::Constants::MAX_RHYTHMS, Helpers::Constants::MIN_AMPLITUDE, Helpers::Constants::PHASE_LABELS, Helpers::Constants::RHYTHM_TYPES, Helpers::Constants::ULTRADIAN_PERIOD

Instance Method Summary collapse

Instance Method Details

#add_cognitive_rhythm(name:, rhythm_type:, dimension:, period: nil, amplitude: 0.5, phase_offset: 0.0) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 13

def add_cognitive_rhythm(name:, rhythm_type:, dimension:, period: nil,
                         amplitude: 0.5, phase_offset: 0.0, **)
  rhythm = engine.add_rhythm(
    name:         name,
    rhythm_type:  rhythm_type,
    dimension:    dimension,
    period:       period,
    amplitude:    amplitude,
    phase_offset: phase_offset
  )
  return { success: false, reason: :limit_reached_or_invalid } unless rhythm

  { success: true, rhythm_id: rhythm.id, name: rhythm.name, dimension: rhythm.dimension }
end

#best_time_for_task(dimension:, within: 3600) ⇒ Object



46
47
48
49
50
51
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 46

def best_time_for_task(dimension:, within: 3600, **)
  time = engine.best_time_for(dimension: dimension, within: within)
  return { success: false, reason: :no_rhythms_for_dimension } unless time

  { success: true, dimension: dimension, best_time: time.iso8601, within_seconds: within }
end

#cognitive_rhythm_profileObject



53
54
55
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 53

def cognitive_rhythm_profile(**)
  { success: true, profile: engine.cognitive_profile }
end

#cognitive_rhythm_statsObject



67
68
69
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 67

def cognitive_rhythm_stats(**)
  { success: true }.merge(engine.to_h)
end

#current_rhythm_stateObject



33
34
35
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 33

def current_rhythm_state(**)
  { success: true, state: engine.current_state }
end

#dimension_rhythm_value(dimension:) ⇒ Object



37
38
39
40
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 37

def dimension_rhythm_value(dimension:, **)
  value = engine.dimension_value(dimension: dimension)
  { success: true, dimension: dimension, value: value.round(4) }
end

#optimal_for_task(dimension:) ⇒ Object



42
43
44
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 42

def optimal_for_task(dimension:, **)
  { success: true, dimension: dimension, optimal: engine.optimal_for(dimension: dimension) }
end

#peak_cognitive_dimensionsObject



57
58
59
60
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 57

def peak_cognitive_dimensions(**)
  dims = engine.peak_dimensions
  { success: true, dimensions: dims, count: dims.size }
end

#remove_cognitive_rhythm(rhythm_id:) ⇒ Object



28
29
30
31
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 28

def remove_cognitive_rhythm(rhythm_id:, **)
  result = engine.remove_rhythm(rhythm_id: rhythm_id)
  result[:success] ? result : { success: false, reason: result[:reason] }
end

#trough_cognitive_dimensionsObject



62
63
64
65
# File 'lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb', line 62

def trough_cognitive_dimensions(**)
  dims = engine.trough_dimensions
  { success: true, dimensions: dims, count: dims.size }
end