Class: Legion::Extensions::Agentic::Social::MoralReasoning::Helpers::Dilemma

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb

Constant Summary

Constants included from Constants

Constants::DECAY_RATE, Constants::DEFAULT_WEIGHT, Constants::ETHICAL_FRAMEWORKS, Constants::KOHLBERG_LEVELS, Constants::KOHLBERG_STAGES, Constants::MAX_DILEMMAS, Constants::MAX_HISTORY, Constants::MAX_PRINCIPLES, Constants::MORAL_FOUNDATIONS, Constants::REINFORCEMENT_RATE, Constants::SEVERITY_LABELS, Constants::WEIGHT_CEILING, Constants::WEIGHT_FLOOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, description:, options:, domain: :general, severity: 0.5) ⇒ Dilemma

Returns a new instance of Dilemma.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 16

def initialize(id:, description:, options:, domain: :general, severity: 0.5)
  @id           = id
  @description  = description
  @domain       = domain
  @severity     = severity.clamp(0.0, 1.0)
  @options      = options
  @chosen_option = nil
  @reasoning = nil
  @framework_used = nil
  @resolved     = false
  @created_at   = Time.now.utc
  @resolved_at  = nil
end

Instance Attribute Details

#chosen_optionObject (readonly)

Returns the value of attribute chosen_option.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def chosen_option
  @chosen_option
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def description
  @description
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def domain
  @domain
end

#framework_usedObject (readonly)

Returns the value of attribute framework_used.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def framework_used
  @framework_used
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def id
  @id
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def options
  @options
end

#reasoningObject (readonly)

Returns the value of attribute reasoning.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def reasoning
  @reasoning
end

#resolved_atObject (readonly)

Returns the value of attribute resolved_at.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def resolved_at
  @resolved_at
end

#severityObject (readonly)

Returns the value of attribute severity.



12
13
14
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 12

def severity
  @severity
end

Instance Method Details

#resolve(option_id:, reasoning:, framework:) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 34

def resolve(option_id:, reasoning:, framework:)
  @chosen_option  = option_id
  @reasoning      = reasoning
  @framework_used = framework
  @resolved       = true
  @resolved_at    = Time.now.utc
end

#resolved?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 42

def resolved?
  @resolved
end

#severity_labelObject



30
31
32
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 30

def severity_label
  SEVERITY_LABELS.find { |range, _| range.cover?(@severity) }&.last
end

#to_hObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/legion/extensions/agentic/social/moral_reasoning/helpers/dilemma.rb', line 46

def to_h
  {
    id:             @id,
    description:    @description,
    domain:         @domain,
    severity:       @severity,
    severity_label: severity_label,
    options:        @options,
    chosen_option:  @chosen_option,
    reasoning:      @reasoning,
    framework_used: @framework_used,
    resolved:       @resolved,
    created_at:     @created_at,
    resolved_at:    @resolved_at
  }
end