Module: Legion::Extensions::Agentic::Learning::Plasticity::Runners::CognitivePlasticity

Includes:
Helpers::Constants, Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb

Constant Summary

Constants included from Helpers::Constants

Helpers::Constants::CRITICAL_PERIOD_MULTIPLIER, Helpers::Constants::DEFAULT_LEARNING_RATE, Helpers::Constants::MATURATION_RATE, Helpers::Constants::MAX_EVENTS, Helpers::Constants::MAX_PATHWAYS, Helpers::Constants::PATHWAY_TYPES, Helpers::Constants::PLASTICITY_LABELS, Helpers::Constants::PRUNING_THRESHOLD, Helpers::Constants::STRENGTHENING_RATE, Helpers::Constants::STRENGTH_LABELS

Instance Method Summary collapse

Instance Method Details

#create_pathway(label:, engine: nil, pathway_type: :synaptic, initial_strength: 0.3) ⇒ Object



14
15
16
17
18
19
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 14

def create_pathway(label:, engine: nil, pathway_type: :synaptic, initial_strength: 0.3, **)
  eng = engine || default_engine
  pathway = eng.create_pathway(label: label, pathway_type: pathway_type,
                               initial_strength: initial_strength)
  { success: true, pathway: pathway.to_h }
end

#enter_critical_period(engine: nil) ⇒ Object



45
46
47
48
49
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 45

def enter_critical_period(engine: nil, **)
  eng = engine || default_engine
  eng.enter_critical_period!
  { success: true, critical_period: true }
end

#exit_critical_period(engine: nil) ⇒ Object



51
52
53
54
55
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 51

def exit_critical_period(engine: nil, **)
  eng = engine || default_engine
  eng.exit_critical_period!
  { success: true, critical_period: false }
end

#plasticity_report(engine: nil) ⇒ Object



69
70
71
72
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 69

def plasticity_report(engine: nil, **)
  eng = engine || default_engine
  { success: true, report: eng.plasticity_report }
end

#prune_weak_pathways(engine: nil) ⇒ Object



57
58
59
60
61
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 57

def prune_weak_pathways(engine: nil, **)
  eng = engine || default_engine
  pruned = eng.prune_weak_pathways!
  { success: true, pruned_count: pruned }
end

#rejuvenate_pathway(pathway_id:, engine: nil, amount: 0.1) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 37

def rejuvenate_pathway(pathway_id:, engine: nil, amount: 0.1, **)
  eng = engine || default_engine
  result = eng.rejuvenate_pathway(pathway_id: pathway_id, amount: amount)
  return { success: false, error: 'pathway not found' } unless result

  { success: true, pathway: result.to_h }
end

#strengthen_pathway(pathway_id:, engine: nil, amount: STRENGTHENING_RATE) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 21

def strengthen_pathway(pathway_id:, engine: nil, amount: STRENGTHENING_RATE, **)
  eng = engine || default_engine
  result = eng.strengthen_pathway(pathway_id: pathway_id, amount: amount)
  return { success: false, error: 'pathway not found' } unless result

  { success: true, pathway: result.to_h }
end

#strongest_pathways(engine: nil, limit: 5) ⇒ Object



63
64
65
66
67
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 63

def strongest_pathways(engine: nil, limit: 5, **)
  eng = engine || default_engine
  pathways = eng.strongest_pathways(limit: limit).map(&:to_h)
  { success: true, pathways: pathways, count: pathways.size }
end

#weaken_pathway(pathway_id:, engine: nil, amount: STRENGTHENING_RATE) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/legion/extensions/agentic/learning/plasticity/runners/cognitive_plasticity.rb', line 29

def weaken_pathway(pathway_id:, engine: nil, amount: STRENGTHENING_RATE, **)
  eng = engine || default_engine
  result = eng.weaken_pathway(pathway_id: pathway_id, amount: amount)
  return { success: false, error: 'pathway not found' } unless result

  { success: true, pathway: result.to_h }
end