Module: Legion::Extensions::Synapse::Runners::Dream
- Included in:
- Client
- Defined in:
- lib/legion/extensions/synapse/runners/dream.rb
Instance Method Summary collapse
- #dream_replay(synapse_id: nil) ⇒ Object
- #dream_simulate(synapse_id:, mutation_type:, changes:) ⇒ Object
Instance Method Details
#dream_replay(synapse_id: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/synapse/runners/dream.rb', line 12 def dream_replay(synapse_id: nil, **) Data::Model.define_synapse_model Data::Model.define_synapse_mutation_model synapses = if synapse_id s = Data::Model::Synapse[synapse_id] s ? [s] : [] else Data::Model::Synapse.where { version > 1 }.all end replays = synapses.map { |s| replay_mutations(s) } { success: true, replays: replays, count: replays.size } end |
#dream_simulate(synapse_id:, mutation_type:, changes:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/legion/extensions/synapse/runners/dream.rb', line 31 def dream_simulate(synapse_id:, mutation_type:, changes:, **) Data::Model.define_synapse_model synapse = Data::Model::Synapse[synapse_id] return { success: false, error: 'synapse not found' } unless synapse before = snapshot_state(synapse) simulated = apply_simulated_changes(before, mutation_type, changes) simulated_confidence = Helpers::Confidence.adjust( simulated[:confidence] || synapse.confidence, :success ) simulated_mode = Helpers::Confidence.autonomy_mode(simulated_confidence) { success: true, synapse_id: synapse.id, before: before, simulated: simulated, simulated_confidence: simulated_confidence, simulated_mode: simulated_mode, recommendation: simulated_confidence > synapse.confidence ? :apply : :skip } end |