Module: Legion::Extensions::Agentic::Homeostasis::FatigueModel::Runners::CognitiveFatigueModel

Includes:
Helpers::Lex
Included in:
Client, Helpers::Client
Defined in:
lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb

Instance Method Summary collapse

Instance Method Details

#channel_fatigue_status(channel_name:) ⇒ Object



31
32
33
34
35
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 31

def channel_fatigue_status(channel_name:, **)
  result = engine.channel_status(channel_name: channel_name)
  log.debug("[cognitive_fatigue] status: channel=#{channel_name} energy=#{result[:energy]}")
  result
end

#cognitive_fatigue_model_statsObject



71
72
73
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 71

def cognitive_fatigue_model_stats(**)
  engine.to_h
end

#cognitive_quality_reportObject



59
60
61
62
63
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 59

def cognitive_quality_report(**)
  report = engine.quality_report
  log.debug("[cognitive_fatigue] quality: channels=#{report.keys.join(',')}")
  { quality: report }
end

#fatigue_recommendationsObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 48

def fatigue_recommendations(**)
  recommendations = engine.delegation_recommendations
  needs_rest      = engine.channels_needing_rest
  log.debug("[cognitive_fatigue] recommendations: delegate=#{recommendations.size} rest=#{needs_rest.size}")
  {
    delegate:          recommendations,
    rest:              needs_rest,
    any_action_needed: recommendations.any? || needs_rest.any?
  }
end

#overall_fatigue_reportObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 37

def overall_fatigue_report(**)
  fatigue = engine.overall_fatigue
  most_fatigued = engine.most_fatigued_channel
  log.debug("[cognitive_fatigue] overall: fatigue=#{fatigue.round(4)}")
  {
    overall_fatigue:       fatigue.round(4),
    most_fatigued:         most_fatigued,
    channels_needing_rest: engine.channels_needing_rest
  }
end

#process_cognitive_task(channel_name:) ⇒ Object



13
14
15
16
17
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 13

def process_cognitive_task(channel_name:, **)
  result = engine.process_task(channel_name: channel_name)
  log.debug("[cognitive_fatigue] task: channel=#{channel_name} energy=#{result[:energy]} label=#{result[:label]}")
  { channel: result, overall_fatigue: engine.overall_fatigue.round(4) }
end

#rest_all_channelsObject



25
26
27
28
29
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 25

def rest_all_channels(**)
  result = engine.rest_all
  log.debug("[cognitive_fatigue] rest all: overall=#{result[:overall_fatigue]}")
  result
end

#rest_cognitive_channel(channel_name:) ⇒ Object



19
20
21
22
23
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 19

def rest_cognitive_channel(channel_name:, **)
  result = engine.rest_channel(channel_name: channel_name)
  log.debug("[cognitive_fatigue] rest channel: channel=#{channel_name} energy=#{result[:energy]}")
  { channel: result }
end

#update_cognitive_fatigue_modelObject



65
66
67
68
69
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 65

def update_cognitive_fatigue_model(**)
  result = engine.rest_all
  log.info('[cognitive_fatigue] model updated: all channels rested')
  result
end