Class: Legion::Extensions::Agentic::Inference::Coherence::Helpers::Proposition
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::Coherence::Helpers::Proposition
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb
Constant Summary
Constants included from Constants
Constants::ACCEPTANCE_THRESHOLD, Constants::COHERENCE_LABELS, Constants::COHERENCE_WEIGHT, Constants::CONSTRAINT_TYPES, Constants::DECAY_RATE, Constants::DEFAULT_ACCEPTANCE, Constants::INCOHERENCE_PENALTY, Constants::MAX_CONSTRAINTS, Constants::MAX_HISTORY, Constants::MAX_PROPOSITIONS, Constants::PROPOSITION_STATES
Instance Attribute Summary collapse
-
#acceptance ⇒ Object
readonly
Returns the value of attribute acceptance.
-
#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_count ⇒ Object
readonly
Returns the value of attribute evidence_count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#negative_constraints ⇒ Object
readonly
Returns the value of attribute negative_constraints.
-
#positive_constraints ⇒ Object
readonly
Returns the value of attribute positive_constraints.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #accepted? ⇒ Boolean
- #add_evidence ⇒ Object
- #add_negative_constraint(proposition_id:) ⇒ Object
- #add_positive_constraint(proposition_id:) ⇒ Object
- #adjust_acceptance(amount:) ⇒ Object
-
#initialize(content:, domain: :general, acceptance: DEFAULT_ACCEPTANCE) ⇒ Proposition
constructor
A new instance of Proposition.
- #rejected? ⇒ Boolean
- #state ⇒ Object
- #to_h ⇒ Object
- #undecided? ⇒ Boolean
Constructor Details
#initialize(content:, domain: :general, acceptance: DEFAULT_ACCEPTANCE) ⇒ Proposition
Returns a new instance of Proposition.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 18 def initialize(content:, domain: :general, acceptance: DEFAULT_ACCEPTANCE) @id = SecureRandom.uuid @content = content @domain = domain @acceptance = acceptance.clamp(0.0, 1.0) @positive_constraints = [] @negative_constraints = [] @evidence_count = 0 @created_at = Time.now.utc @updated_at = Time.now.utc end |
Instance Attribute Details
#acceptance ⇒ Object (readonly)
Returns the value of attribute acceptance.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def acceptance @acceptance end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.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/inference/coherence/helpers/proposition.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/inference/coherence/helpers/proposition.rb', line 14 def domain @domain end |
#evidence_count ⇒ Object (readonly)
Returns the value of attribute evidence_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def evidence_count @evidence_count end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def id @id end |
#negative_constraints ⇒ Object (readonly)
Returns the value of attribute negative_constraints.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def negative_constraints @negative_constraints end |
#positive_constraints ⇒ Object (readonly)
Returns the value of attribute positive_constraints.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def positive_constraints @positive_constraints end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 14 def updated_at @updated_at end |
Instance Method Details
#accepted? ⇒ Boolean
40 41 42 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 40 def accepted? state == :accepted end |
#add_evidence ⇒ Object
74 75 76 77 78 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 74 def add_evidence @evidence_count += 1 @updated_at = Time.now.utc @evidence_count end |
#add_negative_constraint(proposition_id:) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 60 def add_negative_constraint(proposition_id:) return false if @negative_constraints.include?(proposition_id) @negative_constraints << proposition_id @updated_at = Time.now.utc true end |
#add_positive_constraint(proposition_id:) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 52 def add_positive_constraint(proposition_id:) return false if @positive_constraints.include?(proposition_id) @positive_constraints << proposition_id @updated_at = Time.now.utc true end |
#adjust_acceptance(amount:) ⇒ Object
68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 68 def adjust_acceptance(amount:) @acceptance = (@acceptance + amount).clamp(0.0, 1.0) @updated_at = Time.now.utc @acceptance end |
#rejected? ⇒ Boolean
44 45 46 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 44 def rejected? state == :rejected end |
#state ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 30 def state if @acceptance >= ACCEPTANCE_THRESHOLD :accepted elsif @acceptance < (1.0 - ACCEPTANCE_THRESHOLD) :rejected else :undecided end end |
#to_h ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 80 def to_h { id: @id, content: @content, domain: @domain, acceptance: @acceptance, state: state, positive_constraints: @positive_constraints.dup, negative_constraints: @negative_constraints.dup, evidence_count: @evidence_count, created_at: @created_at, updated_at: @updated_at } end |
#undecided? ⇒ Boolean
48 49 50 |
# File 'lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb', line 48 def undecided? state == :undecided end |