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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:, content:, confidence: 0.7, importance: :moderate) ⇒ Belief

Returns a new instance of Belief.



14
15
16
17
18
19
20
21
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/belief.rb', line 14

def initialize(domain:, content:, confidence: 0.7, importance: :moderate)
  @id         = SecureRandom.uuid
  @domain     = domain
  @content    = content
  @confidence = confidence.clamp(0.0, 1.0)
  @importance = importance
  @created_at = Time.now.utc
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



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

def confidence
  @confidence
end

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/belief.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/belief.rb', line 12

def id
  @id
end

#importanceObject (readonly)

Returns the value of attribute importance.



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

def importance
  @importance
end

Instance Method Details

#contradicts?(other) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/belief.rb', line 23

def contradicts?(other)
  return false if id == other.id
  return false unless domain == other.domain

  content.strip.downcase != other.content.strip.downcase
end

#to_hObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/legion/extensions/agentic/defense/dissonance/helpers/belief.rb', line 30

def to_h
  {
    id:         id,
    domain:     domain,
    content:    content,
    confidence: confidence,
    importance: importance,
    created_at: created_at
  }
end