Class: Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Claim
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Claim
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb
Constant Summary
Constants included from Constants
Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::CLAIM_VERDICTS, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::COHERENCE_WEIGHT, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::CONSISTENCY_WEIGHT, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::DECAY_RATE, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::DEFAULT_SOURCE_RELIABILITY, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::MAX_CLAIMS, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::MAX_HISTORY, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::MAX_SOURCES, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::RELIABILITY_BOOST, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::RELIABILITY_PENALTY, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::SOURCE_RELIABILITY_LABELS, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::SOURCE_WEIGHT, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::VIGILANCE_LEVELS, Legion::Extensions::Agentic::Defense::EpistemicVigilance::Helpers::Constants::VIGILANCE_THRESHOLDS
Instance Attribute Summary collapse
-
#confidence ⇒ Object
Returns the value of attribute confidence.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#evidence_against ⇒ Object
readonly
Returns the value of attribute evidence_against.
-
#evidence_for ⇒ Object
readonly
Returns the value of attribute evidence_for.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#source_id ⇒ Object
readonly
Returns the value of attribute source_id.
-
#verdict ⇒ Object
readonly
Returns the value of attribute verdict.
Instance Method Summary collapse
- #adjudicate!(verdict:) ⇒ Object
- #challenge! ⇒ Object
- #contested? ⇒ Boolean
- #credibility_ratio ⇒ Object
-
#initialize(content:, source_id:, domain:, confidence: 0.5) ⇒ Claim
constructor
A new instance of Claim.
- #support! ⇒ Object
- #to_h ⇒ Object
- #well_supported? ⇒ Boolean
Constructor Details
#initialize(content:, source_id:, domain:, confidence: 0.5) ⇒ Claim
Returns a new instance of Claim.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 18 def initialize(content:, source_id:, domain:, confidence: 0.5) @id = SecureRandom.uuid @content = content @source_id = source_id @domain = domain @confidence = confidence.clamp(0.0, 1.0) @verdict = :suspended @evidence_for = 0 @evidence_against = 0 @created_at = Time.now.utc end |
Instance Attribute Details
#confidence ⇒ Object
Returns the value of attribute confidence.
16 17 18 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 16 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def domain @domain end |
#evidence_against ⇒ Object (readonly)
Returns the value of attribute evidence_against.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def evidence_against @evidence_against end |
#evidence_for ⇒ Object (readonly)
Returns the value of attribute evidence_for.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def evidence_for @evidence_for end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def id @id end |
#source_id ⇒ Object (readonly)
Returns the value of attribute source_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def source_id @source_id end |
#verdict ⇒ Object (readonly)
Returns the value of attribute verdict.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 14 def verdict @verdict end |
Instance Method Details
#adjudicate!(verdict:) ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 52 def adjudicate!(verdict:) @verdict = verdict end |
#challenge! ⇒ Object
35 36 37 38 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 35 def challenge! @evidence_against += 1 @confidence = (@confidence - 0.08).clamp(0.0, 1.0) end |
#contested? ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 44 def contested? @evidence_against.positive? && credibility_ratio < 0.6 end |
#credibility_ratio ⇒ Object
40 41 42 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 40 def credibility_ratio @evidence_for / (@evidence_for + @evidence_against + 1.0) end |
#support! ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 30 def support! @evidence_for += 1 @confidence = (@confidence + 0.05).clamp(0.0, 1.0) end |
#to_h ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 56 def to_h { id: @id, content: @content, source_id: @source_id, domain: @domain, confidence: @confidence, verdict: @verdict, evidence_for: @evidence_for, evidence_against: @evidence_against, credibility_ratio: credibility_ratio, contested: contested?, well_supported: well_supported?, created_at: @created_at } end |
#well_supported? ⇒ Boolean
48 49 50 |
# File 'lib/legion/extensions/agentic/defense/epistemic_vigilance/helpers/claim.rb', line 48 def well_supported? @evidence_for >= 3 && credibility_ratio > 0.7 end |