Module: Legion::Extensions::Agentic::Social::Mirror::Runners::Simulate
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/social/mirror/runners/simulate.rb
Instance Method Summary collapse
- #record_simulation_accuracy(simulation_id:, accuracy:, engine: nil) ⇒ Object
- #simulate_action(event_id:, confidence: Helpers::Constants::SIMULATION_CONFIDENCE_DEFAULT, engine: nil) ⇒ Object
- #simulation_history(limit: 20, engine: nil) ⇒ Object
Instance Method Details
#record_simulation_accuracy(simulation_id:, accuracy:, engine: nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/simulate.rb', line 33 def record_simulation_accuracy(simulation_id:, accuracy:, engine: nil, **) eng = engine || mirror_engine recorded = eng.record_accuracy(simulation_id, accuracy) unless recorded log.debug "[cognitive_mirror] record_accuracy: simulation_id=#{simulation_id} not found" return { success: false, error: 'simulation not found', simulation_id: simulation_id } end log.debug "[cognitive_mirror] accuracy recorded simulation=#{simulation_id} score=#{accuracy}" { success: true, simulation_id: simulation_id, accuracy: accuracy.to_f.clamp(0.0, 1.0) } end |
#simulate_action(event_id:, confidence: Helpers::Constants::SIMULATION_CONFIDENCE_DEFAULT, engine: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/simulate.rb', line 13 def simulate_action(event_id:, confidence: Helpers::Constants::SIMULATION_CONFIDENCE_DEFAULT, engine: nil, **) eng = engine || mirror_engine event = eng.events.find { |e| e.id == event_id } unless event log.debug "[cognitive_mirror] simulate_action: event_id=#{event_id} not found" return { success: false, error: 'event not found', event_id: event_id } end sim = eng.simulate(event, confidence: confidence) eng.boost_resonance(event.agent_id) confidence_label = Helpers::Constants.label_for(Helpers::Constants::CONFIDENCE_LABELS, sim.confidence) log.debug "[cognitive_mirror] simulated event=#{event_id} " \ "confidence_tier=#{confidence_label} resonance=#{sim.emotional_resonance.round(3)}" { success: true, simulation: sim.to_h, confidence_tier: confidence_label } end |
#simulation_history(limit: 20, engine: nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/social/mirror/runners/simulate.rb', line 46 def simulation_history(limit: 20, engine: nil, **) eng = engine || mirror_engine history = eng.simulation_history(limit: limit) { success: true, simulations: history, count: history.size } end |