Class: SuperInstance::Equipment::ConsensusEngine::ConflictResolution

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(config = {}) ⇒ ConflictResolution

Creates a new ConflictResolution instance

Parameters:

  • config (Hash) (defaults to: {})

    Optional configuration overrides



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_historyObject

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_historyArray<Hash>

Gets the resolution history

Returns:

  • (Array<Hash>)

    Resolution history



58
59
60
# File 'lib/equipment/consensus_engine/conflict_resolution.rb', line 58

def get_history
  @resolution_history.dup
end

#get_statsHash

Gets statistics about resolutions

Returns:

  • (Hash)

    Resolution statistics



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

Parameters:

  • conflict (Hash)

    The conflict to resolve

  • opinions (Array<Hash>)

    Current perspective opinions

Returns:

  • (Hash)

    The resolution result



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