Skip to content
Tracon

AgentFileStoreContract

Namespace Tracon.Testing.Contracts.Storage · Assembly Tracon.Testing.Contracts.Xunit.dll

Tenant isolation contract for the persistent agent file memory.

public abstract class AgentFileStoreContract : TenantIsolationContract<AgentFileStore>, IAsyncLifetime, IAsyncDisposable
Inheritance
object ← StoreCancellationContract<AgentFileStore> ← TenantIsolationContract<AgentFileStore> ← AgentFileStoreContract
Implements
IAsyncLifetime, IAsyncDisposable
Inherited Members
TenantIsolationContract<AgentFileStore>.TenantA, TenantIsolationContract<AgentFileStore>.TenantB, TenantIsolationContract<AgentFileStore>.UseAmbientTenant(MutableTenantContext), TenantIsolationContract<AgentFileStore>.SeedAsync(string, string, CancellationToken), TenantIsolationContract<AgentFileStore>.ExistsAsync(string, object), TenantIsolationContract<AgentFileStore>.CountAsync(string, CancellationToken), TenantIsolationContract<AgentFileStore>.TryDeleteAsync(string, object), TenantIsolationContract<AgentFileStore>.TryOverwriteAsync(string, string), TenantIsolationContract<AgentFileStore>.CancellableReadAsync(CancellationToken), TenantIsolationContract<AgentFileStore>.CancellableWriteAsync(CancellationToken), TenantIsolationContract<AgentFileStore>.WroteAnythingAsync(), TenantIsolationContract<AgentFileStore>.Tenant_cannot_read_another_tenants_record(), TenantIsolationContract<AgentFileStore>.Tenant_reads_its_own_record(), TenantIsolationContract<AgentFileStore>.Tenant_does_not_see_another_tenants_record_in_the_list(), TenantIsolationContract<AgentFileStore>.Tenant_cannot_delete_another_tenants_record(), TenantIsolationContract<AgentFileStore>.Same_name_lives_independently_across_two_tenants(), TenantIsolationContract<AgentFileStore>.AmbientTenant, StoreCancellationContract<AgentFileStore>.CreateStoreAsync(), StoreCancellationContract<AgentFileStore>.InitializeAsync(), StoreCancellationContract<AgentFileStore>.DisposeAsync(), StoreCancellationContract<AgentFileStore>.OnDisposeAsync(), StoreCancellationContract<AgentFileStore>.CancellableReadAsync(CancellationToken), StoreCancellationContract<AgentFileStore>.CancellableWriteAsync(CancellationToken), StoreCancellationContract<AgentFileStore>.WroteAnythingAsync(), StoreCancellationContract<AgentFileStore>.Canceled_token_throws_on_read(), StoreCancellationContract<AgentFileStore>.The_write_this_contract_checks_can_be_read_back(), StoreCancellationContract<AgentFileStore>.Canceled_token_throws_on_write_and_leaves_no_trace(), StoreCancellationContract<AgentFileStore>.Store, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

File memory is not an IStore; it is the Microsoft Agent Framework AI.AgentFileStore type. The tenant is read from ITenantContext, and the agent name is read from an implementation-defined ambient scope that AgentFileStoreContract.EnterRunScope establishes – Tracon’s own stores read it from TraconRunContext (Tracon.Core), which this package deliberately does not reference (it depends on Tracon.Abstractions only).

The ambient scope is set up at the start of each test body, not in InitializeAsync: the xunit v3 (MTP) lifecycle hook can run the test body as a separately scheduled task, which breaks an AsyncLocal-based flow.

protected AgentFileStoreContract()

Reports how many records the given tenant sees through the listing endpoint.

protected override ValueTask<int> CountAsync(string tenantId, CancellationToken cancellationToken)

tenantId string

The reading tenant.

cancellationToken CancellationToken

The token every store call inside the hook must be handed; see TenantIsolationContract.SeedAsync.

ValueTask<int>

The number of records seen.

Creating_a_directory_does_not_produce_a_record()

Section titled “ Creating_a_directory_does_not_produce_a_record()”
[Fact]
public Task Creating_a_directory_does_not_produce_a_record()

Task

Sets the active tenant and establishes the ambient run scope.

protected void Enter(string tenantId)

tenantId string

The tenant id.

Establishes whatever ambient run scope the store under test reads the agent name from. Tracon’s own SQL-backed implementations read TraconRunContext.Current (Tracon.Core); a derived contract in a project that already references Tracon.Core sets that up here.

protected abstract void EnterRunScope()

Reports whether the record is visible from the given tenant’s viewpoint.

protected override ValueTask<bool> ExistsAsync(string tenantId, object key)

tenantId string

The reading tenant.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool>

true if the record is visible.

Clears the ambient run scope AgentFileStoreContract.EnterRunScope established.

protected abstract void ExitRunScope()
[Fact]
public Task Glob_filter_narrows_by_file_name()

Task

Hook for a derived class to release its own resources.

protected override ValueTask OnDisposeAsync()

ValueTask

A completed task.

Recursive_false_skips_matches_in_subdirectories()

Section titled “ Recursive_false_skips_matches_in_subdirectories()”
[Fact]
public Task Recursive_false_skips_matches_in_subdirectories()

Task

Search_does_not_find_another_tenants_file()

Section titled “ Search_does_not_find_another_tenants_file()”
[Fact]
public Task Search_does_not_find_another_tenants_file()

Task

Search_in_a_large_store_returns_only_the_target_directory()

Section titled “ Search_in_a_large_store_returns_only_the_target_directory()”
[Fact]
public Task Search_in_a_large_store_returns_only_the_target_directory()

Task

SeedAsync(string, string, CancellationToken)

Section titled “ SeedAsync(string, string, CancellationToken)”

Writes a sample record for the given tenant.

protected override ValueTask<object> SeedAsync(string tenantId, string name, CancellationToken cancellationToken)

tenantId string

The tenant that owns the record.

name string

The name distinguishing the record. The same name may be used by two tenants.

cancellationToken CancellationToken

The token every store call inside the hook must be handed. The cancellation contract calls this hook with a token that is already cancelled, so a hook that drops the token reports a store as sound when it is not.

ValueTask<object>

The key to use for reading the record back.

Attempts to delete the record on behalf of the given tenant.

protected override ValueTask<bool?> TryDeleteAsync(string tenantId, object key)

tenantId string

The tenant attempting the delete.

key object

The key returned by TenantIsolationContract.SeedAsync.

ValueTask<bool?>

true if the delete succeeded, false if the record was not found; null if the store does not offer deletion.