Module: Legion::Extensions::Agentic::Social::Trust::Helpers::TrustModel

Defined in:
lib/legion/extensions/agentic/social/trust/helpers/trust_model.rb

Constant Summary collapse

TRUST_DIMENSIONS =

Trust is emergent, multidimensional, domain-specific (spec design-decisions-v5 #4)

%i[reliability competence integrity benevolence].freeze
TRUST_CONSIDER_THRESHOLD =

Thresholds

0.3
TRUST_DELEGATE_THRESHOLD =

minimum trust to consider agent’s input

0.7
TRUST_DECAY_RATE =

minimum trust to delegate actions

0.005
TRUST_REINFORCEMENT =

per-cycle decay

0.05
TRUST_PENALTY =

per positive interaction

0.15
NEUTRAL_TRUST =

per negative interaction (asymmetric)

0.3

Class Method Summary collapse

Class Method Details

.clamp(value, min = 0.0, max = 1.0) ⇒ Object



43
44
45
# File 'lib/legion/extensions/agentic/social/trust/helpers/trust_model.rb', line 43

def clamp(value, min = 0.0, max = 1.0)
  value.clamp(min, max)
end

.composite_score(dimensions) ⇒ Object



37
38
39
40
41
# File 'lib/legion/extensions/agentic/social/trust/helpers/trust_model.rb', line 37

def composite_score(dimensions)
  return 0.0 if dimensions.empty?

  dimensions.values.sum / dimensions.size
end

.new_trust_entry(agent_id:, domain: :general) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/legion/extensions/agentic/social/trust/helpers/trust_model.rb', line 23

def new_trust_entry(agent_id:, domain: :general)
  {
    agent_id:          agent_id,
    domain:            domain,
    dimensions:        TRUST_DIMENSIONS.to_h { |d| [d, NEUTRAL_TRUST] },
    composite:         NEUTRAL_TRUST,
    interaction_count: 0,
    positive_count:    0,
    negative_count:    0,
    last_interaction:  nil,
    created_at:        Time.now.utc
  }
end