Class: Legion::Extensions::Agentic::Inference::BeliefRevision::Helpers::Evidence

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb

Constant Summary

Constants included from Constants

Constants::BELIEF_STATES, Constants::CONTRADICTION_THRESHOLD, Constants::CREDENCE_CEILING, Constants::CREDENCE_FLOOR, Constants::CREDENCE_LABELS, Constants::DECAY_RATE, Constants::DEFAULT_CREDENCE, Constants::ENTRENCHMENT_ALPHA, Constants::EVIDENCE_TYPES, Constants::EVIDENCE_WEIGHT, Constants::LINK_TYPES, Constants::MAX_BELIEFS, Constants::MAX_EVIDENCE_PER_BELIEF, Constants::MAX_HISTORY, Constants::MAX_LINKS, Constants::STATE_THRESHOLDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, evidence_type:, content:, weight: EVIDENCE_WEIGHT, source: :unknown) ⇒ Evidence

Returns a new instance of Evidence.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 14

def initialize(id:, evidence_type:, content:, weight: EVIDENCE_WEIGHT, source: :unknown)
  raise ArgumentError, "invalid type: #{evidence_type}" unless EVIDENCE_TYPES.include?(evidence_type)

  @id            = id
  @evidence_type = evidence_type
  @content       = content
  @weight        = weight.to_f.clamp(0.0, 1.0)
  @source        = source
  @created_at    = Time.now.utc
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def created_at
  @created_at
end

#evidence_typeObject (readonly)

Returns the value of attribute evidence_type.



12
13
14
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 12

def evidence_type
  @evidence_type
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 12

def id
  @id
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 12

def source
  @source
end

#weightObject (readonly)

Returns the value of attribute weight.



12
13
14
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 12

def weight
  @weight
end

Instance Method Details

#strong?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 25

def strong?
  @weight >= 0.5
end

#to_hObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 33

def to_h
  {
    id:            @id,
    evidence_type: @evidence_type,
    content:       @content,
    weight:        @weight.round(4),
    source:        @source,
    created_at:    @created_at
  }
end

#weak?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb', line 29

def weak?
  @weight < 0.2
end