Class: Legion::Extensions::Agentic::Executive::DissonanceResolution::Helpers::DissonanceConflict
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::DissonanceResolution::Helpers::DissonanceConflict
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb
Constant Summary
Constants included from Constants
Constants::DEFAULT_TENSION, Constants::MAX_CONFLICTS, Constants::MAX_STRATEGIES, Constants::OUTCOME_LABELS, Constants::RESOLUTION_THRESHOLD, Constants::STRATEGIES, Constants::TENSION_DECAY, Constants::TENSION_LABELS
Instance Attribute Summary collapse
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#belief_a ⇒ Object
readonly
Returns the value of attribute belief_a.
-
#belief_b ⇒ Object
readonly
Returns the value of attribute belief_b.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#resolved_at ⇒ Object
readonly
Returns the value of attribute resolved_at.
-
#strategy_used ⇒ Object
readonly
Returns the value of attribute strategy_used.
-
#tension ⇒ Object
readonly
Returns the value of attribute tension.
Instance Method Summary collapse
- #abandon! ⇒ Object
- #apply_strategy!(strategy:, effectiveness: 0.3) ⇒ Object
- #decay! ⇒ Object
- #escalate!(amount: 0.15) ⇒ Object
-
#initialize(belief_a:, belief_b:, domain: :general, tension: DEFAULT_TENSION) ⇒ DissonanceConflict
constructor
A new instance of DissonanceConflict.
- #resolved? ⇒ Boolean
- #tension_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(belief_a:, belief_b:, domain: :general, tension: DEFAULT_TENSION) ⇒ DissonanceConflict
Returns a new instance of DissonanceConflict.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 17 def initialize(belief_a:, belief_b:, domain: :general, tension: DEFAULT_TENSION) @id = SecureRandom.uuid @belief_a = belief_a @belief_b = belief_b @domain = domain.to_sym @tension = tension.to_f.clamp(0.0, 1.0) @strategy_used = nil @outcome = :ongoing @attempts = 0 @created_at = Time.now.utc @resolved_at = nil end |
Instance Attribute Details
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def attempts @attempts end |
#belief_a ⇒ Object (readonly)
Returns the value of attribute belief_a.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def belief_a @belief_a end |
#belief_b ⇒ Object (readonly)
Returns the value of attribute belief_b.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def belief_b @belief_b end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def id @id end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def outcome @outcome end |
#resolved_at ⇒ Object (readonly)
Returns the value of attribute resolved_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def resolved_at @resolved_at end |
#strategy_used ⇒ Object (readonly)
Returns the value of attribute strategy_used.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def strategy_used @strategy_used end |
#tension ⇒ Object (readonly)
Returns the value of attribute tension.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 14 def tension @tension end |
Instance Method Details
#abandon! ⇒ Object
62 63 64 65 66 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 62 def abandon! @outcome = :abandoned @resolved_at = Time.now.utc self end |
#apply_strategy!(strategy:, effectiveness: 0.3) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 39 def apply_strategy!(strategy:, effectiveness: 0.3) @strategy_used = strategy.to_sym @attempts += 1 reduction = effectiveness.to_f.clamp(0.0, 0.5) @tension = (@tension - reduction).clamp(0.0, 1.0).round(10) @outcome = :resolved if resolved? @resolved_at = Time.now.utc if resolved? self end |
#decay! ⇒ Object
55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 55 def decay! @tension = (@tension - TENSION_DECAY).clamp(0.0, 1.0).round(10) @outcome = :resolved if resolved? && @outcome == :ongoing @resolved_at = Time.now.utc if resolved? && @resolved_at.nil? self end |
#escalate!(amount: 0.15) ⇒ Object
49 50 51 52 53 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 49 def escalate!(amount: 0.15) @tension = (@tension + amount).clamp(0.0, 1.0).round(10) @outcome = :escalated if @tension >= 0.9 self end |
#resolved? ⇒ Boolean
35 36 37 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 35 def resolved? @tension <= RESOLUTION_THRESHOLD end |
#tension_label ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 30 def tension_label match = TENSION_LABELS.find { |range, _| range.cover?(@tension) } match ? match.last : :resolved end |
#to_h ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/legion/extensions/agentic/executive/dissonance_resolution/helpers/dissonance_conflict.rb', line 68 def to_h { id: @id, belief_a: @belief_a, belief_b: @belief_b, domain: @domain, tension: @tension, tension_label: tension_label, resolved: resolved?, strategy_used: @strategy_used, outcome: @outcome, attempts: @attempts, created_at: @created_at, resolved_at: @resolved_at } end |