Record Class ReputationScore

java.lang.Object
java.lang.Record
com.tnsai.accountability.ReputationScore
Record Components:
agentId - identity the score belongs to
score - normalised aggregate, [0.0, 1.0]
recordCount - how many records the score was computed from
computedAt - wall-clock instant of computation; useful for cache-staleness checks downstream

public record ReputationScore(String agentId, double score, int recordCount, Instant computedAt) extends Record
Aggregate reputation derived from an agent's AgentLiabilityRecord history (TNS-298).

Score is normalised to [0.0, 1.0] where 1.0 means "every recorded action stayed within scope and produced a successful outcome" and 0.0 means "every recorded action either exceeded scope or failed". The mid-band reflects partial success; the ReputationLedger implementation defines how it weighs LiabilityClass severity (one HIGH miss outweighs many LOW misses by convention, but ledgers can use other policies).

Since:
0.10.0 (TNS-298)
  • Constructor Details

    • ReputationScore

      public ReputationScore(String agentId, double score, int recordCount, Instant computedAt)
      Creates an instance of a ReputationScore record class.
      Parameters:
      agentId - the value for the agentId record component
      score - the value for the score record component
      recordCount - the value for the recordCount record component
      computedAt - the value for the computedAt record component
  • Method Details

    • unknown

      public static ReputationScore unknown(String agentId, Instant computedAt)
      Score for an agent with no recorded history. Convention is 1.0 — innocent until proven otherwise — so a fresh agent doesn't fail "minimum reputation" gates on its first call. Operators who want stricter onboarding return a lower score for unknown agents in their custom ledger.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • score

      public double score()
      Returns the value of the score record component.
      Returns:
      the value of the score record component
    • recordCount

      public int recordCount()
      Returns the value of the recordCount record component.
      Returns:
      the value of the recordCount record component
    • computedAt

      public Instant computedAt()
      Returns the value of the computedAt record component.
      Returns:
      the value of the computedAt record component