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
- #channel_fatigue_status(channel_name:) ⇒ Object
- #cognitive_fatigue_model_stats ⇒ Object
- #cognitive_quality_report ⇒ Object
- #fatigue_recommendations ⇒ Object
- #overall_fatigue_report ⇒ Object
- #process_cognitive_task(channel_name:) ⇒ Object
- #rest_all_channels ⇒ Object
- #rest_cognitive_channel(channel_name:) ⇒ Object
- #update_cognitive_fatigue_model ⇒ Object
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_stats ⇒ Object
75 76 77 |
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 75 def cognitive_fatigue_model_stats(**) engine.to_h end |
#cognitive_quality_report ⇒ Object
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_recommendations ⇒ Object
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_report ⇒ Object
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_channels ⇒ Object
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_model ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb', line 65 def update_cognitive_fatigue_model(**) depleted = engine.channels_needing_rest rested_channels = depleted.map { |ch| engine.rest_channel(channel_name: ch[:name]) } log.info("[cognitive_fatigue] model updated: #{depleted.size} depleted channels rested") { rested: depleted.size, channels: rested_channels, overall_fatigue: engine.overall_fatigue.round(4) } rescue StandardError => e log.error("[cognitive_fatigue] update_cognitive_fatigue_model failed: #{e.}") { rested: 0, channels: [], error: e. } end |