# RunScoreRules

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.runscorerules/
> Summary: RunScoreRules: The shared rules a RunScore must satisfy before it is stored.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The shared rules a [RunScore](/api/tracon.runscore/) must satisfy before it is stored.

```csharp
public static class RunScoreRules
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.runscorerules/">RunScoreRules</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

Public because [IRunScoreStore](/api/tracon.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](/api/tracon.runscorerules/#Tracon_RunScoreRules_IsValidName_System_String_) and the
[RunScoreKind.Categorical](/api/tracon.runscorekind/) invariant itself so it can answer
`400` instead of letting the store throw.

## Fields

### <a id="Tracon_RunScoreRules_DefaultName"></a> DefaultName

The name written when a caller supplies none.

```csharp
public const string DefaultName = "overall"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Remarks

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

### <a id="Tracon_RunScoreRules_MaxEvaluatorVersionLength"></a> MaxEvaluatorVersionLength

The greatest allowed [RunScore.EvaluatorVersion](/api/tracon.runscore/#Tracon_RunScore_EvaluatorVersion) length.

```csharp
public const int MaxEvaluatorVersionLength = 128
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Remarks

A version is a short identifier: a release number, optionally with a
pre-release label and a source revision. The bound keeps the stored
column fixed-width, because the value is one a judge supplies — an
unbounded column would let a third-party judge decide how much of a
customer's table a single score row occupies.

### <a id="Tracon_RunScoreRules_MaxNameLength"></a> MaxNameLength

The greatest allowed [RunScore.Name](/api/tracon.runscore/#Tracon_RunScore_Name) length.

```csharp
public const int MaxNameLength = 64
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_RunScoreRules_MaxTextValueLength"></a> MaxTextValueLength

The greatest allowed [RunScore.TextValue](/api/tracon.runscore/#Tracon_RunScore_TextValue) length.

```csharp
public const int MaxTextValueLength = 256
```

#### Field Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

### <a id="Tracon_RunScoreRules_NameDescription"></a> NameDescription

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

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

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Methods

### <a id="Tracon_RunScoreRules_IsValidName_System_String_"></a> IsValidName\(string?\)

Reports whether `name` is a legal score name.

```csharp
public static bool IsValidName(string? name)
```

#### Parameters

`name` [string](https://learn.microsoft.com/dotnet/api/system.string)?

The candidate name.

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

[true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the name matches `[A-Za-z0-9._-]{1,64}`.

### <a id="Tracon_RunScoreRules_Validate_Tracon_RunScore_"></a> Validate\(RunScore\)

Throws when `score` breaks a stored invariant.

```csharp
public static void Validate(RunScore score)
```

#### Parameters

`score` [RunScore](/api/tracon.runscore/)

The score about to be written.

#### Remarks

The value-shape invariant: a [RunScoreKind.Categorical](/api/tracon.runscorekind/)
score carries [RunScore.TextValue](/api/tracon.runscore/#Tracon_RunScore_TextValue) and no
[RunScore.Value](/api/tracon.runscore/#Tracon_RunScore_Value); every other kind carries
[RunScore.Value](/api/tracon.runscore/#Tracon_RunScore_Value) and no [RunScore.TextValue](/api/tracon.runscore/#Tracon_RunScore_TextValue).
A [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) [RunScore.Value](/api/tracon.runscore/#Tracon_RunScore_Value) stays legal on the
other kinds — it records that no measurement was made.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`score` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The name breaks [RunScoreRules.NameDescription](/api/tracon.runscorerules/#Tracon_RunScoreRules_NameDescription), the value shape does not
match [RunScore.Kind](/api/tracon.runscore/#Tracon_RunScore_Kind), or
[RunScore.EvaluatorVersion](/api/tracon.runscore/#Tracon_RunScore_EvaluatorVersion) is longer than
[RunScoreRules.MaxEvaluatorVersionLength](/api/tracon.runscorerules/#Tracon_RunScoreRules_MaxEvaluatorVersionLength).
