Module: Legion::Extensions::Agentic::Executive::Load::Runners::CognitiveLoad

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb

Instance Method Summary collapse

Instance Method Details

#adjust_capacity(new_capacity:) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 54

def adjust_capacity(new_capacity:, **)
  model = load_model
  before = model.capacity
  model.adjust_capacity(new_capacity: new_capacity)
  after = model.capacity
  Legion::Logging.debug "[cognitive_load] capacity adjusted: before=#{before.round(2)} after=#{after.round(2)}"
  { success: true, before: before.round(4), after: after.round(4), current_state: model.to_h }
end

#cognitive_load_statsObject



86
87
88
89
90
91
92
93
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 86

def cognitive_load_stats(**)
  model = load_model
  history = model.load_history

  stats = compute_history_stats(history)
  Legion::Logging.debug "[cognitive_load] stats: history_size=#{history.size} avg_ratio=#{stats[:avg_load_ratio]}"
  { success: true, history_size: history.size, stats: stats, current_state: model.to_h }
end

#load_recommendationObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 71

def load_recommendation(**)
  model = load_model
  rec = model.recommendation
  Legion::Logging.debug "[cognitive_load] recommendation: #{rec}"
  {
    success:        true,
    recommendation: rec,
    load_label:     model.load_label,
    load_ratio:     model.load_ratio.round(4),
    germane_ratio:  model.germane_ratio.round(4),
    overloaded:     model.overloaded?,
    underloaded:    model.underloaded?
  }
end

#load_statusObject



63
64
65
66
67
68
69
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 63

def load_status(**)
  model = load_model
  status = model.to_h
  Legion::Logging.debug "[cognitive_load] status: label=#{status[:load_label]} " \
                        "overloaded=#{status[:overloaded]} underloaded=#{status[:underloaded]}"
  { success: true, status: status }
end

#reduce_overhead(amount:) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 37

def reduce_overhead(amount:, **)
  model = load_model
  before = model.extraneous
  model.reduce_extraneous(amount: amount)
  after = model.extraneous
  Legion::Logging.debug "[cognitive_load] overhead reduced: before=#{before.round(2)} after=#{after.round(2)} delta=#{(before - after).round(2)}"
  { success: true, before: before.round(4), after: after.round(4), delta: (before - after).round(4), current_state: model.to_h }
end

#report_extraneous(amount:, source: :unknown) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 21

def report_extraneous(amount:, source: :unknown, **)
  model = load_model
  model.add_extraneous(amount: amount, source: source)
  Legion::Logging.debug "[cognitive_load] extraneous reported: amount=#{amount} source=#{source} " \
                        "ratio=#{model.load_ratio.round(2)} label=#{model.load_label}"
  { success: true, load_type: :extraneous, amount: amount, source: source, current_state: model.to_h }
end

#report_germane(amount:, source: :unknown) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 29

def report_germane(amount:, source: :unknown, **)
  model = load_model
  model.add_germane(amount: amount, source: source)
  Legion::Logging.debug "[cognitive_load] germane reported: amount=#{amount} source=#{source} " \
                        "ratio=#{model.load_ratio.round(2)} label=#{model.load_label}"
  { success: true, load_type: :germane, amount: amount, source: source, current_state: model.to_h }
end

#report_intrinsic(amount:, source: :unknown) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 13

def report_intrinsic(amount:, source: :unknown, **)
  model = load_model
  model.add_intrinsic(amount: amount, source: source)
  Legion::Logging.debug "[cognitive_load] intrinsic reported: amount=#{amount} source=#{source} " \
                        "ratio=#{model.load_ratio.round(2)} label=#{model.load_label}"
  { success: true, load_type: :intrinsic, amount: amount, source: source, current_state: model.to_h }
end

#update_cognitive_loadObject



46
47
48
49
50
51
52
# File 'lib/legion/extensions/agentic/executive/load/runners/cognitive_load.rb', line 46

def update_cognitive_load(**)
  model = load_model
  model.decay
  snapshot = model.to_h
  Legion::Logging.debug "[cognitive_load] tick decay: ratio=#{snapshot[:load_ratio]} label=#{snapshot[:load_label]}"
  { success: true, action: :decay, current_state: snapshot }
end