Class: Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Source
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Source
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb
Constant Summary
Constants included from Constants
Constants::CLAIM_VERDICTS, Constants::COHERENCE_WEIGHT, Constants::CONSISTENCY_WEIGHT, Constants::DECAY_RATE, Constants::DEFAULT_SOURCE_RELIABILITY, Constants::MAX_CLAIMS, Constants::MAX_HISTORY, Constants::MAX_SOURCES, Constants::RELIABILITY_BOOST, Constants::RELIABILITY_PENALTY, Constants::SOURCE_RELIABILITY_LABELS, Constants::SOURCE_WEIGHT, Constants::VIGILANCE_LEVELS, Constants::VIGILANCE_THRESHOLDS
Instance Attribute Summary collapse
-
#claims_made ⇒ Object
readonly
Returns the value of attribute claims_made.
-
#claims_refuted ⇒ Object
readonly
Returns the value of attribute claims_refuted.
-
#claims_verified ⇒ Object
readonly
Returns the value of attribute claims_verified.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#reliability ⇒ Object
Returns the value of attribute reliability.
Instance Method Summary collapse
-
#initialize(name:, domain:) ⇒ Source
constructor
A new instance of Source.
- #record_refuted! ⇒ Object
- #record_verified! ⇒ Object
- #reliability_label ⇒ Object
- #to_h ⇒ Object
- #track_record ⇒ Object
Constructor Details
#initialize(name:, domain:) ⇒ Source
Returns a new instance of Source.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 17 def initialize(name:, domain:) @id = SecureRandom.uuid @name = name @domain = domain @reliability = DEFAULT_SOURCE_RELIABILITY @claims_made = 0 @claims_verified = 0 @claims_refuted = 0 end |
Instance Attribute Details
#claims_made ⇒ Object (readonly)
Returns the value of attribute claims_made.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def claims_made @claims_made end |
#claims_refuted ⇒ Object (readonly)
Returns the value of attribute claims_refuted.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def claims_refuted @claims_refuted end |
#claims_verified ⇒ Object (readonly)
Returns the value of attribute claims_verified.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def claims_verified @claims_verified end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 14 def name @name end |
#reliability ⇒ Object
Returns the value of attribute reliability.
15 16 17 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 15 def reliability @reliability end |
Instance Method Details
#record_refuted! ⇒ Object
32 33 34 35 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 32 def record_refuted! @claims_refuted += 1 @reliability = (@reliability - RELIABILITY_PENALTY).clamp(0.0, 1.0) end |
#record_verified! ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 27 def record_verified! @claims_verified += 1 @reliability = (@reliability + RELIABILITY_BOOST).clamp(0.0, 1.0) end |
#reliability_label ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 37 def reliability_label SOURCE_RELIABILITY_LABELS.find { |range, _label| range.include?(@reliability) }&.last || :uncertain end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 45 def to_h { id: @id, name: @name, domain: @domain, reliability: @reliability, reliability_label: reliability_label, claims_made: @claims_made, claims_verified: @claims_verified, claims_refuted: @claims_refuted, track_record: track_record } end |
#track_record ⇒ Object
41 42 43 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/source.rb', line 41 def track_record @claims_verified / (@claims_verified + @claims_refuted + 1.0) end |