Record Class Score

java.lang.Object
java.lang.Record
com.tnsai.quality.tracing.Score
Record Components:
name - score name (e.g. "quality", "relevance", "toxicity")
value - numeric value (0.0 for false, 1.0 for true in boolean mode)
type - the type of score value
source - who/what produced the score
observationId - optional id linking this score to a specific observation (null for trace-level)
label - optional categorical label (only meaningful for ScoreType.CATEGORICAL)

public record Score(String name, double value, ScoreType type, ScoreSource source, String observationId, String label) extends Record
A score attached to a trace or observation.

Scores can be numeric (0.0-1.0 continuous), boolean (pass/fail), or categorical (label). Each score records its source (human, model, or heuristic) for provenance tracking.

Instances are immutable.

  • Constructor Details

    • Score

      public Score(String name, double value, ScoreType type, ScoreSource source, String observationId, String label)
      Creates an instance of a Score record class.
      Parameters:
      name - the value for the name record component
      value - the value for the value record component
      type - the value for the type record component
      source - the value for the source record component
      observationId - the value for the observationId record component
      label - the value for the label record component
  • Method Details

    • numeric

      public static Score numeric(String name, double value, ScoreSource source)
      Creates a numeric score (0.0 to 1.0 range).
    • bool

      public static Score bool(String name, boolean passed, ScoreSource source)
      Creates a boolean score (pass=1.0, fail=0.0).
    • categorical

      public static Score categorical(String name, String label, ScoreSource source)
      Creates a categorical score with a label.
    • forObservation

      public Score forObservation(String observationId)
      Returns a copy of this score bound to the given observation.
    • 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.
    • name

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

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

      public ScoreType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • source

      public ScoreSource source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • observationId

      public String observationId()
      Returns the value of the observationId record component.
      Returns:
      the value of the observationId record component
    • label

      public String label()
      Returns the value of the label record component.
      Returns:
      the value of the label record component