Module: Legion::Extensions::Agentic::Homeostasis::NeuralOscillation::Runners::NeuralOscillation
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb
Instance Method Summary collapse
- #activate_band(oscillator_id:, band:, amount: nil) ⇒ Object
- #add_oscillator(id:, domain: :general) ⇒ Object
- #couple_oscillators(oscillator_a:, oscillator_b:, band:) ⇒ Object
- #decouple_oscillators(oscillator_a:, oscillator_b:, band:) ⇒ Object
- #desynchronize_band(band:) ⇒ Object
- #global_rhythm ⇒ Object
- #neural_oscillation_stats ⇒ Object
- #suppress_band(oscillator_id:, band:, amount: nil) ⇒ Object
- #synchrony_for_band(band:) ⇒ Object
- #update_neural_oscillations ⇒ Object
Instance Method Details
#activate_band(oscillator_id:, band:, amount: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 23 def activate_band(oscillator_id:, band:, amount: nil, **) amt = amount || Helpers::Constants::DEFAULT_POWER log.debug("[neural_oscillation] activate: osc=#{oscillator_id} band=#{band}") osc = network.activate_band(oscillator_id: oscillator_id, band: band.to_sym, amount: amt) if osc { success: true, oscillator: osc.to_h } else { success: false, reason: :not_found } end end |
#add_oscillator(id:, domain: :general) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 13 def add_oscillator(id:, domain: :general, **) log.debug("[neural_oscillation] add: id=#{id} domain=#{domain}") osc = network.add_oscillator(id: id, domain: domain) if osc { success: true, oscillator: osc.to_h } else { success: false, reason: :limit_reached } end end |
#couple_oscillators(oscillator_a:, oscillator_b:, band:) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 45 def couple_oscillators(oscillator_a:, oscillator_b:, band:, **) log.debug("[neural_oscillation] couple: #{oscillator_a}<->#{oscillator_b} band=#{band}") c = network.couple(oscillator_a: oscillator_a, oscillator_b: oscillator_b, band: band.to_sym) if c { success: true, coupling: c.to_h } else { success: false, reason: :invalid_pair } end end |
#decouple_oscillators(oscillator_a:, oscillator_b:, band:) ⇒ Object
55 56 57 58 59 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 55 def decouple_oscillators(oscillator_a:, oscillator_b:, band:, **) log.debug("[neural_oscillation] decouple: #{oscillator_a}<->#{oscillator_b}") removed = network.decouple(oscillator_a: oscillator_a, oscillator_b: oscillator_b, band: band.to_sym) { success: removed } end |
#desynchronize_band(band:) ⇒ Object
73 74 75 76 77 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 73 def desynchronize_band(band:, **) log.debug("[neural_oscillation] desync band=#{band}") network.desynchronize(band: band.to_sym) { success: true, band: band.to_sym } end |
#global_rhythm ⇒ Object
61 62 63 64 65 66 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 61 def global_rhythm(**) rhythm = network.global_rhythm state = network.cognitive_state log.debug("[neural_oscillation] rhythm=#{rhythm} state=#{state}") { success: true, rhythm: rhythm, cognitive_state: state, synchrony: network.network_synchrony.round(4) } end |
#neural_oscillation_stats ⇒ Object
85 86 87 88 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 85 def neural_oscillation_stats(**) log.debug('[neural_oscillation] stats') { success: true, stats: network.to_h } end |
#suppress_band(oscillator_id:, band:, amount: nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 34 def suppress_band(oscillator_id:, band:, amount: nil, **) amt = amount || Helpers::Constants::DEFAULT_POWER log.debug("[neural_oscillation] suppress: osc=#{oscillator_id} band=#{band}") osc = network.suppress_band(oscillator_id: oscillator_id, band: band.to_sym, amount: amt) if osc { success: true, oscillator: osc.to_h } else { success: false, reason: :not_found } end end |
#synchrony_for_band(band:) ⇒ Object
68 69 70 71 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 68 def synchrony_for_band(band:, **) level = network.synchrony_for(band: band.to_sym) { success: true, band: band.to_sym, synchrony: level.round(4) } end |
#update_neural_oscillations ⇒ Object
79 80 81 82 83 |
# File 'lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb', line 79 def update_neural_oscillations(**) log.debug('[neural_oscillation] tick') network.tick { success: true, rhythm: network.global_rhythm, oscillators: network.oscillators.size } end |