Module: Legion::Extensions::Agentic::Homeostasis::Weathering::Runners::CognitiveWeathering

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb

Instance Method Summary collapse

Instance Method Details

#apply_stressor(description:, stressor_type: :cognitive_overload, intensity: 0.5, duration: 3600, domain: nil) ⇒ Object



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

def apply_stressor(description:, stressor_type: :cognitive_overload, intensity: 0.5,
                   duration: 3600, domain: nil, **)
  stressor = Helpers::Stressor.new(
    description:   description,
    stressor_type: stressor_type,
    intensity:     intensity,
    duration:      duration,
    domain:        domain
  )

  result = weathering_engine.apply_stressor(stressor)
  log.debug("[cognitive_weathering] stressor applied: type=#{stressor_type} " \
            "intensity=#{intensity} impact=#{stressor.cumulative_impact.round(4)} " \
            "integrity=#{result[:integrity].round(4)} fragile=#{result[:fragile]}")
  result.merge(stressor: stressor.to_h)
end

#integrity_statusObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb', line 50

def integrity_status(**)
  engine = weathering_engine
  {
    integrity:          engine.integrity.round(10),
    integrity_label:    Helpers::Constants.integrity_label(engine.integrity),
    tempering_level:    engine.tempering_level.round(10),
    weathering_label:   Helpers::Constants.weathering_label(engine.tempering_level),
    effective_capacity: engine.effective_capacity,
    fragile:            engine.fragile?,
    breaking:           engine.breaking?
  }
end

#recover(amount: 1.0) ⇒ Object



30
31
32
33
34
# File 'lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb', line 30

def recover(amount: 1.0, **)
  result = weathering_engine.recover!(amount)
  log.debug("[cognitive_weathering] recovery: amount=#{amount} integrity=#{result[:integrity].round(4)}")
  result
end

#rest(amount: 1.0) ⇒ Object



36
37
38
39
40
# File 'lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb', line 36

def rest(amount: 1.0, **)
  result = weathering_engine.rest!(amount)
  log.debug("[cognitive_weathering] rest: amount=#{amount} integrity=#{result[:integrity].round(4)}")
  result
end

#weathering_reportObject



42
43
44
45
46
47
48
# File 'lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb', line 42

def weathering_report(**)
  report = weathering_engine.weathering_report
  log.debug("[cognitive_weathering] report: integrity=#{report[:integrity_label]} " \
            "capacity=#{report[:effective_capacity].round(4)} " \
            "stressors=#{report[:stressor_count]}")
  report
end