# ContractCoverage

> 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.testing.contracts.contractcoverage/
> Summary: ContractCoverage: Verifies that a test assembly derives every contract class this package ships for one contract family, so a class dropped during a refactor or never picked up.

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

Verifies that a test assembly derives every contract class this package
ships for one contract family, so a class dropped during a refactor or
never picked up for a new implementation is caught at build time instead of
silently reducing coverage.

```csharp
public static class ContractCoverage
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.testing.contracts.contractcoverage/">ContractCoverage</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

Tracon's own four store implementations (in-memory, PostgreSQL, SQL
Server, SQLite) each call [ContractCoverage.MissingDerivedTypes](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_MissingDerivedTypes_System_Reflection_Assembly_System_String_System_Collections_Generic_IReadOnlyCollection_System_String__) from their own
test assembly; a third-party implementation can do the same.

Every call names a **family** — the namespace the contracts
live in, such as [ContractCoverage.StorageContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_StorageContracts) or
[ContractCoverage.ProviderContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_ProviderContracts). There is deliberately no family-less
overload: one used to exist, and adding a second family to this package
would have made every existing caller fail with contracts that were never
theirs to implement. A store implementer's coverage check must not start
failing because Tracon published a model-provider contract.

## Fields

### <a id="Tracon_Testing_Contracts_ContractCoverage_AgentSourceContracts"></a> AgentSourceContracts

The namespace holding agent-source contracts.

```csharp
public const string AgentSourceContracts = "Tracon.Testing.Contracts.AgentSources"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_JudgeContracts"></a> JudgeContracts

The namespace holding run judge contracts.

```csharp
public const string JudgeContracts = "Tracon.Testing.Contracts.Judges"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_ProviderContracts"></a> ProviderContracts

The namespace holding the model-provider contracts.

```csharp
public const string ProviderContracts = "Tracon.Testing.Contracts.Providers"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_SchedulingContracts"></a> SchedulingContracts

The namespace holding job handler contracts.

```csharp
public const string SchedulingContracts = "Tracon.Testing.Contracts.Scheduling"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_ScriptContracts"></a> ScriptContracts

The namespace holding skill script executor contracts.

```csharp
public const string ScriptContracts = "Tracon.Testing.Contracts.Scripts"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_StorageContracts"></a> StorageContracts

The namespace holding the store contracts (`IRunStore` and the rest).

```csharp
public const string StorageContracts = "Tracon.Testing.Contracts.Storage"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_Testing_Contracts_ContractCoverage_ToolContracts"></a> ToolContracts

The namespace holding custom tool contracts.

```csharp
public const string ToolContracts = "Tracon.Testing.Contracts.Tools"
```

#### Field Value

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

### <a id="Tracon_Testing_Contracts_ContractCoverage_ContractTypes_System_String_"></a> ContractTypes\(string\)

The contract classes this package ships for one family: every
non-generic `public abstract` type in
`namespaceScope` whose name ends in `Contract`.

```csharp
[RequiresUnreferencedCode("Reflects over every type in this assembly. Build-time test infrastructure only; never called from application code.")]
public static IReadOnlyList<Type> ContractTypes(string namespaceScope)
```

#### Parameters

`namespaceScope` [string](https://learn.microsoft.com/dotnet/api/system.string)

The contract family, normally [ContractCoverage.StorageContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_StorageContracts) or
[ContractCoverage.ProviderContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_ProviderContracts).

#### Returns

 [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[Type](https://learn.microsoft.com/dotnet/api/system.type)\>

The contract types, ordered by name.

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

`namespaceScope` is empty, or names no contract type
at all. A namespace that matches nothing is a typo, not an empty
family: reporting zero contracts would make a coverage check pass
while checking nothing.

### <a id="Tracon_Testing_Contracts_ContractCoverage_MissingDerivedTypes_System_Reflection_Assembly_System_String_System_Collections_Generic_IReadOnlyCollection_System_String__"></a> MissingDerivedTypes\(Assembly, string, IReadOnlyCollection<string\>?\)

The contract classes in one family that `consumerAssembly`
declares no concrete derived type for.

```csharp
[RequiresUnreferencedCode("Reflects over every type in the consumer assembly. Build-time test infrastructure only; never called from application code.")]
public static IReadOnlyList<string> MissingDerivedTypes(Assembly consumerAssembly, string namespaceScope, IReadOnlyCollection<string>? except = null)
```

#### Parameters

`consumerAssembly` [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

The test assembly to check, typically `Assembly.GetExecutingAssembly`
from the caller.

`namespaceScope` [string](https://learn.microsoft.com/dotnet/api/system.string)

The contract family to check, normally [ContractCoverage.StorageContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_StorageContracts)
or [ContractCoverage.ProviderContracts](/api/tracon.testing.contracts.contractcoverage/#Tracon_Testing_Contracts_ContractCoverage_ProviderContracts). Contracts outside it are ignored,
so a consumer that implements one family is unaffected by the others.

`except` [IReadOnlyCollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlycollection\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\>?

Contract type names this assembly intentionally does not cover (for
example, a contract for a store shape this deployment does not offer).
A name that does not match any contract type is itself reported back,
the same way `TenantCoverageTests.Coverage_list_carries_no_stale_entries`
catches a stale exemption: an exemption for a contract that no longer
exists, or was never spelled correctly, must not silently pass.

#### Returns

 [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\>

The names of the uncovered, non-exempt contract types, ordered by
name, followed by any stale `except` entry (prefixed
`"stale exemption: "`); empty when every contract type is either
covered or validly exempted.

#### Exceptions

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

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

`namespaceScope` names no contract type.
