Package com.tnsai.coordination.trust
Class TrustRegistry
java.lang.Object
com.tnsai.coordination.trust.TrustRegistry
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 Summary
Modifier and TypeMethodDescriptionvoidApplies decay to all trust scores.voidclear()Clears all trust data.static TrustRegistrycreate(TrustUpdateStrategy strategy, double initialScore) Creates a new TrustRegistry.static TrustRegistrycreate(TrustUpdateStrategy strategy, double initialScore, double decayRate) Creates a new TrustRegistry with decay.getAgentsAboveThreshold(String capability, double threshold) Gets all agents with trust above the threshold for a capability.doubleGets the trust score for an agent on a capability.getTrustScore(String agentId, String capability) Gets the full TrustScore object.rankAgents(String capability, int topN) Ranks agents by trust score for a given capability.voidrecordOutcome(String agentId, String capability, Outcome outcome, double quality) Records an interaction outcome and updates the trust score.intsize()Gets the total number of tracked agent-capability pairs.
-
Method Details
-
create
Creates a new TrustRegistry.- Parameters:
strategy- the update strategyinitialScore- 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 strategyinitialScore- default score for new agentsdecayRate- trust decay rate per decay cycle
-
recordOutcome
Records an interaction outcome and updates the trust score.- Parameters:
agentId- the agent identifiercapability- the capability/skill being evaluatedoutcome- SUCCESS, PARTIAL, or FAILUREquality- quality of the outcome (0.0 - 1.0)
-
getTrust
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
Gets the full TrustScore object. -
rankAgents
Ranks agents by trust score for a given capability.- Parameters:
capability- the capability to rank bytopN- maximum number of agents to return- Returns:
- list of agent IDs sorted by trust score (highest first)
-
getAgentsAboveThreshold
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.
-