Module: Legion::Extensions::Agentic::Social::Trust::Runners::Trust

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/social/trust/runners/trust.rb

Instance Method Summary collapse

Instance Method Details

#decay_trustObject



46
47
48
49
50
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 46

def decay_trust(**)
  decayed = trust_map.decay_all
  log.debug "[trust] decay cycle: entries_updated=#{decayed}"
  { decayed: decayed }
end

#delegatable_agents(domain: :general) ⇒ Object



59
60
61
62
63
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 59

def delegatable_agents(domain: :general, **)
  agents = trust_map.delegatable_agents(domain: domain)
  log.debug "[trust] delegatable agents: domain=#{domain} count=#{agents.size}"
  { agents: agents, count: agents.size }
end

#get_trust(agent_id:, domain: :general) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 13

def get_trust(agent_id:, domain: :general, **)
  entry = trust_map.get(agent_id, domain: domain)
  if entry
    log.debug "[trust] get agent=#{agent_id} domain=#{domain} composite=#{entry[:composite].round(2)}"
    { found: true, trust: entry }
  else
    log.debug "[trust] get agent=#{agent_id} domain=#{domain} not found"
    { found: false, agent_id: agent_id, domain: domain }
  end
end

#record_trust_interaction(agent_id:, positive:, domain: :general) ⇒ Object



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

def record_trust_interaction(agent_id:, positive:, domain: :general, **)
  entry = trust_map.record_interaction(agent_id, domain: domain, positive: positive)
  msg = "[trust] interaction: agent=#{agent_id} domain=#{domain} positive=#{positive} " \
        "composite=#{entry[:composite].round(2)} total=#{entry[:interaction_count]}"
  log.info msg
  {
    agent_id:     agent_id,
    domain:       domain,
    positive:     positive,
    composite:    entry[:composite],
    interactions: entry[:interaction_count]
  }
end

#reinforce_trust_dimension(agent_id:, dimension:, domain: :general, amount: nil) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 38

def reinforce_trust_dimension(agent_id:, dimension:, domain: :general, amount: nil, **)
  amt = amount || Helpers::TrustModel::TRUST_REINFORCEMENT
  trust_map.reinforce_dimension(agent_id, domain: domain, dimension: dimension, amount: amt)
  entry = trust_map.get(agent_id, domain: domain)
  log.debug "[trust] reinforce: agent=#{agent_id} dimension=#{dimension} amount=#{amt} composite=#{entry[:composite].round(2)}"
  { agent_id: agent_id, domain: domain, dimension: dimension, composite: entry[:composite] }
end

#trust_statusObject



65
66
67
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 65

def trust_status(**)
  { total_entries: trust_map.count }
end

#trusted_agents(domain: :general, min_trust: nil) ⇒ Object



52
53
54
55
56
57
# File 'lib/legion/extensions/agentic/social/trust/runners/trust.rb', line 52

def trusted_agents(domain: :general, min_trust: nil, **)
  min = min_trust || Helpers::TrustModel::TRUST_CONSIDER_THRESHOLD
  agents = trust_map.trusted_agents(domain: domain, min_trust: min)
  log.debug "[trust] trusted agents: domain=#{domain} min=#{min} count=#{agents.size}"
  { agents: agents, count: agents.size }
end