Class TrustRegistry

java.lang.Object
com.tnsai.coordination.trust.TrustRegistry

public final class TrustRegistry extends Object
Central registry for agent trust scores.

Maintains per-agent, per-capability trust scores that are updated based on interaction outcomes. Thread-safe for concurrent access.

Usage


 TrustRegistry registry = TrustRegistry.create(
     TrustUpdateStrategy.ema(0.3),
     0.5  // initial trust score
 );

 registry.recordOutcome("agent-a", "translation", Outcome.SUCCESS, 0.95);
 registry.recordOutcome("agent-a", "translation", Outcome.PARTIAL, 0.60);

 double trust = registry.getTrust("agent-a", "translation");
 List<String> best = registry.rankAgents("translation", 3);
 
Since:
0.0.5
  • Method Details

    • create

      public static TrustRegistry create(TrustUpdateStrategy strategy, double initialScore)
      Creates a new TrustRegistry.
      Parameters:
      strategy - the update strategy
      initialScore - default score for new agents (0.0 - 1.0)
    • create

      public static TrustRegistry create(TrustUpdateStrategy strategy, double initialScore, double decayRate)
      Creates a new TrustRegistry with decay.
      Parameters:
      strategy - the update strategy
      initialScore - default score for new agents
      decayRate - trust decay rate per decay cycle
    • recordOutcome

      public void recordOutcome(String agentId, String capability, Outcome outcome, double quality)
      Records an interaction outcome and updates the trust score.
      Parameters:
      agentId - the agent identifier
      capability - the capability/skill being evaluated
      outcome - SUCCESS, PARTIAL, or FAILURE
      quality - quality of the outcome (0.0 - 1.0)
    • getTrust

      public double getTrust(String agentId, String capability)
      Gets the trust score for an agent on a capability.
      Returns:
      trust score (0.0 - 1.0), or the initial score if no history
    • getTrustScore

      public Optional<TrustScore> getTrustScore(String agentId, String capability)
      Gets the full TrustScore object.
    • rankAgents

      public List<String> rankAgents(String capability, int topN)
      Ranks agents by trust score for a given capability.
      Parameters:
      capability - the capability to rank by
      topN - maximum number of agents to return
      Returns:
      list of agent IDs sorted by trust score (highest first)
    • getAgentsAboveThreshold

      public List<String> getAgentsAboveThreshold(String capability, double threshold)
      Gets all agents with trust above the threshold for a capability.
    • applyDecay

      public void applyDecay()
      Applies decay to all trust scores. Call this periodically (e.g., daily) to decay stale scores toward neutral.
    • size

      public int size()
      Gets the total number of tracked agent-capability pairs.
    • clear

      public void clear()
      Clears all trust data.