Class: Legion::Extensions::Agentic::Defense::Dissonance::Helpers::DissonanceEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(belief_a_id:, belief_b_id:, domain:, magnitude:, contradiction_type: :direct) ⇒ DissonanceEvent

Returns a new instance of DissonanceEvent.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 15

def initialize(belief_a_id:, belief_b_id:, domain:, magnitude:, contradiction_type: :direct)
  @id                  = SecureRandom.uuid
  @belief_a_id         = belief_a_id
  @belief_b_id         = belief_b_id
  @domain              = domain
  @magnitude           = magnitude.clamp(0.0, 1.0)
  @contradiction_type  = contradiction_type
  @resolved            = false
  @resolution_strategy = nil
  @timestamp           = Time.now.utc
end

Instance Attribute Details

#belief_a_idObject (readonly)

Returns the value of attribute belief_a_id.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def belief_a_id
  @belief_a_id
end

#belief_b_idObject (readonly)

Returns the value of attribute belief_b_id.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def belief_b_id
  @belief_b_id
end

#contradiction_typeObject (readonly)

Returns the value of attribute contradiction_type.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def contradiction_type
  @contradiction_type
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def id
  @id
end

#magnitudeObject (readonly)

Returns the value of attribute magnitude.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def magnitude
  @magnitude
end

#resolution_strategyObject (readonly)

Returns the value of attribute resolution_strategy.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def resolution_strategy
  @resolution_strategy
end

#resolvedObject (readonly)

Returns the value of attribute resolved.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def resolved
  @resolved
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 12

def timestamp
  @timestamp
end

Instance Method Details

#resolve!(strategy) ⇒ Object



27
28
29
30
31
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 27

def resolve!(strategy)
  @resolved            = true
  @resolution_strategy = strategy
  self
end

#to_hObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/dissonance_event.rb', line 33

def to_h
  {
    id:                  id,
    belief_a_id:         belief_a_id,
    belief_b_id:         belief_b_id,
    domain:              domain,
    magnitude:           magnitude,
    contradiction_type:  contradiction_type,
    resolved:            resolved,
    resolution_strategy: resolution_strategy,
    timestamp:           timestamp
  }
end