Class: SuperInstance::Equipment::ConsensusEngine::ConflictResolution
- Inherits:
-
Object
- Object
- SuperInstance::Equipment::ConsensusEngine::ConflictResolution
- Defined in:
- lib/equipment/consensus_engine/conflict_resolution.rb
Overview
ConflictResolution - Resolve disagreements between perspectives
Implements strategies for detecting and resolving conflicts when Pathos, Logos, and Ethos perspectives disagree on a proposition.
Constant Summary collapse
- DEFAULT_CONFIG =
Default resolution configuration
{ max_attempts: 3, min_confidence: 0.6, allow_escalation: true }.freeze
Instance Method Summary collapse
-
#clear_history ⇒ Object
Clears the resolution history.
-
#get_history ⇒ Array<Hash>
Gets the resolution history.
-
#get_stats ⇒ Hash
Gets statistics about resolutions.
-
#initialize(config = {}) ⇒ ConflictResolution
constructor
Creates a new ConflictResolution instance.
-
#resolve(conflict, opinions) ⇒ Hash
Resolves a conflict between perspectives.
Constructor Details
#initialize(config = {}) ⇒ ConflictResolution
Creates a new ConflictResolution instance
22 23 24 25 |
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 22 def initialize(config = {}) @config = DEFAULT_CONFIG.merge(config) @resolution_history = [] end |
Instance Method Details
#clear_history ⇒ Object
Clears the resolution history
63 64 65 |
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 63 def clear_history @resolution_history.clear end |
#get_history ⇒ Array<Hash>
Gets the resolution history
58 59 60 |
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 58 def get_history @resolution_history.dup end |
#get_stats ⇒ Hash
Gets statistics about resolutions
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 69 def get_stats total = @resolution_history.length successful = @resolution_history.count { |r| r[:result][:resolved] } strategy_usage = Hash.new(0) total_confidence = 0.0 @resolution_history.each do |entry| strategy_usage[entry[:result][:strategy]] += 1 total_confidence += entry[:result][:confidence] end { total_resolutions: total, successful_resolutions: successful, strategy_usage: strategy_usage, average_confidence: total > 0 ? total_confidence / total : 0 } end |
#resolve(conflict, opinions) ⇒ Hash
Resolves a conflict between perspectives
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 31 def resolve(conflict, opinions) # Select appropriate resolution strategy based on conflict type strategy = select_strategy(conflict, opinions) # Apply the selected strategy result = apply_strategy(strategy, conflict, opinions) # If resolution failed, try alternative strategies attempts = 1 while !result[:resolved] && attempts < @config[:max_attempts] alternative_strategy = select_alternative_strategy(strategy, conflict, result) result = apply_strategy(alternative_strategy, conflict, opinions) attempts += 1 end # Record the resolution attempt @resolution_history << { conflict: conflict, result: result, timestamp: Time.now } result end |