Module: Legion::Extensions::Agentic::Social::Mirror::Runners::Resonance
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/social/mirror/runners/resonance.rb
Instance Method Summary collapse
- #decay_resonances(agent_id: nil, engine: nil) ⇒ Object
- #empathic_resonance(agent_id:, engine: nil) ⇒ Object
- #resonance_summary(engine: nil) ⇒ Object
Instance Method Details
#decay_resonances(agent_id: nil, engine: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/resonance.rb', line 36 def decay_resonances(agent_id: nil, engine: nil, **) eng = engine || mirror_engine if agent_id eng.decay_resonance(agent_id) after = eng.empathic_resonance(agent_id) log.debug "[cognitive_mirror] resonance decayed agent=#{agent_id} after=#{after.round(3)}" { success: true, agent_id: agent_id, resonance_after: after } else eng.decay_all_resonances summary = eng.known_agents.to_h { |id| [id, eng.empathic_resonance(id)] } log.debug "[cognitive_mirror] global resonance decay agents=#{summary.size}" { success: true, agents_decayed: summary.size, resonances: summary } end end |
#empathic_resonance(agent_id:, engine: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/resonance.rb', line 13 def empathic_resonance(agent_id:, engine: nil, **) eng = engine || mirror_engine value = eng.empathic_resonance(agent_id) accuracy = eng.simulation_accuracy_for(agent_id) empathy_label = Helpers::Constants.label_for(Helpers::Constants::EMPATHY_LABELS, value) resonance_label = Helpers::Constants.label_for(Helpers::Constants::RESONANCE_LABELS, value) log.debug "[cognitive_mirror] resonance agent=#{agent_id} " \ "value=#{value.round(3)} empathy=#{empathy_label}" { success: true, agent_id: agent_id, resonance: value, resonance_label: resonance_label, empathy_label: empathy_label, accuracy: accuracy, event_count: eng.events_for(agent_id).size, simulation_count: eng.simulations_for(agent_id).size } end |
#resonance_summary(engine: nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/resonance.rb', line 52 def resonance_summary(engine: nil, **) eng = engine || mirror_engine agents = eng.known_agents summary = agents.map do |id| value = eng.empathic_resonance(id) { agent_id: id, resonance: value, empathy_label: Helpers::Constants.label_for(Helpers::Constants::EMPATHY_LABELS, value) } end { success: true, agents: summary, total: agents.size } end |