Skip to content
Tracon

RunScoreRules

Namespace Tracon · Assembly Tracon.Abstractions.dll

The shared rules a RunScore must satisfy before it is stored.

public static class RunScoreRules

objectRunScoreRules

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Public because IRunScoreStore is an extension point: a consumer’s own store must enforce the same invariants, and the shipped store contract tests hold it to them. Writing the rule a second time by hand would produce a second validation path that drifts.

The Tracon HTTP endpoint calls RunScoreRules.IsValidName and the RunScoreKind.Categorical invariant itself so it can answer 400 instead of letting the store throw.

The name written when a caller supplies none.

public const string DefaultName = "overall"

string

Also the name the migration gives every human score row written before scores had names.

The greatest allowed RunScore.Name length.

public const int MaxNameLength = 64

int

The greatest allowed RunScore.TextValue length.

public const int MaxTextValueLength = 256

int

The human-readable name rule, used in error messages.

public const string NameDescription = "A run score name must match [A-Za-z0-9._-]{1,64}."

string

Reports whether name is a legal score name.

public static bool IsValidName(string? name)

name string?

The candidate name.

bool

true if the name matches [A-Za-z0-9._-]{1,64}.

Throws when score breaks a stored invariant.

public static void Validate(RunScore score)

score RunScore

The score about to be written.

The value-shape invariant: a RunScoreKind.Categorical score carries RunScore.TextValue and no RunScore.Value; every other kind carries RunScore.Value and no RunScore.TextValue. A null RunScore.Value stays legal on the other kinds — it records that no measurement was made.

ArgumentNullException

score is null.

ArgumentException

The name breaks RunScoreRules.NameDescription, or the value shape does not match RunScore.Kind.