Skip to content

AuditingExperimentStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Wraps IExperimentStore in a decorator that writes an audit trail.

public sealed class AuditingExperimentStore : IExperimentStore, IAuditDecorated

objectAuditingExperimentStore

IExperimentStore, IAuditDecorated

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

Creating, starting, or stopping an experiment is a deliberate Admin decision that affects live traffic. It has the same reason as AuditingAgentDefinitionStore and is not an execution byproduct such as IJobStore or IEvalStore.

AuditingExperimentStore(IExperimentStore, IAuditLog, ITenantContext, IAuditActorResolver, ILogger<AuditingExperimentStore>)

Section titled “ AuditingExperimentStore(IExperimentStore, IAuditLog, ITenantContext, IAuditActorResolver, ILogger<AuditingExperimentStore>)”

Initializes a new audited experiment store.

public AuditingExperimentStore(IExperimentStore inner, IAuditLog auditLog, ITenantContext tenantContext, IAuditActorResolver actorResolver, ILogger<AuditingExperimentStore> logger)

inner IExperimentStore

auditLog IAuditLog

tenantContext ITenantContext

actorResolver IAuditActorResolver

logger ILogger<AuditingExperimentStore>

Gets the real store instance the decorator wraps.

public object AuditedInner { get; }

object

AdvanceCanaryRampAsync(string, string, IReadOnlyList<ExperimentVariant>, CancellationToken)

Section titled “ AdvanceCanaryRampAsync(string, string, IReadOnlyList<ExperimentVariant>, CancellationToken)”

Applies a gradual-increase decision from the canary evaluator. The experiment remains ExperimentStatus.Running and only variant weights change. Only the canary evaluation service calls this method.

public ValueTask<Experiment> AdvanceCanaryRampAsync(string tenantId, string name, IReadOnlyList<ExperimentVariant> variants, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

variants IReadOnlyList<ExperimentVariant>

The new variant weights. They must total 100.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The updated experiment.

This method is not audited. Only CanaryEvaluationService calls it, and gradual increases do not enter the audit trail according to the 56.2 flow. Only rollback is written. See AuditingExperimentStore.RollbackCanaryAsync.

DeleteAsync(string, string, CancellationToken)

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

Deletes an experiment. A running experiment must be stopped before deletion.

public ValueTask<bool> DeleteAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true when deletion occurs.

GetAsync(string, string, CancellationToken)

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

Gets the experiment with the specified name.

public ValueTask<Experiment?> GetAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment?>

The experiment, or null when it does not exist.

GetRunningAsync(string, string, CancellationToken)

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

Gets the ExperimentStatus.Running experiment for an agent. Returns null when none exists. An agent can have at most one running experiment at a time.

public ValueTask<Experiment?> GetRunningAsync(string tenantId, string agentName, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

agentName string

The agent name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment?>

The running experiment, or null when none exists.

Lists all experiments for a tenant by name.

public ValueTask<IReadOnlyList<Experiment>> ListAsync(string tenantId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<Experiment>>

The experiments.

ListRunningWithCanaryAsync(CancellationToken)

Section titled “ ListRunningWithCanaryAsync(CancellationToken)”

Lists experiments across all tenants that are ExperimentStatus.Running and define Experiment.Canary.

public ValueTask<IReadOnlyList<Experiment>> ListRunningWithCanaryAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<Experiment>>

The running experiments that define a canary policy.

This is a maintenance operation for the canary evaluator. It scans all tenants for the same reason as IPendingApprovalStore.ExpireAsync.

RollbackCanaryAsync(string, string, IReadOnlyList<ExperimentVariant>, string, CancellationToken)

Section titled “ RollbackCanaryAsync(string, string, IReadOnlyList<ExperimentVariant>, string, CancellationToken)”

Applies an automatic rollback decision from the canary evaluator. It moves the experiment to ExperimentStatus.Stopped, restores weights to the control variant, and writes Experiment.RollbackReason.

public ValueTask<Experiment> RollbackCanaryAsync(string tenantId, string name, IReadOnlyList<ExperimentVariant> variants, string reason, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

variants IReadOnlyList<ExperimentVariant>

The weights restored to the control variant. They must total 100.

reason string

The rollback reason.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The updated experiment.

The caller, the canary evaluation service, must write the audit trail before calling this method. If that write fails, it must not call this method: a rollback that cannot be audited is not applied.

Creates or updates an experiment. Only an ExperimentStatus.Draft experiment can be updated. Updating a started experiment throws an AgentPrismException.

public ValueTask<Experiment> SaveAsync(Experiment experiment, CancellationToken cancellationToken = default)

experiment Experiment

The experiment to save.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The saved experiment.

SetCanaryPolicyAsync(string, string, CanaryPolicy?, CancellationToken)

Section titled “ SetCanaryPolicyAsync(string, string, CanaryPolicy?, CancellationToken)”

Defines or removes an experiment canary policy. Pass null for policy to remove it.

public ValueTask<Experiment> SetCanaryPolicyAsync(string tenantId, string name, CanaryPolicy? policy, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

policy CanaryPolicy?

The new policy, or null to remove it.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The updated experiment.

Unlike IExperimentStore.SaveAsync, this method works regardless of experiment status, Draft or Running. A canary policy can be defined while an experiment already receives traffic.

StartAsync(string, string, CancellationToken)

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

Moves the experiment to ExperimentStatus.Running. Throws an AgentPrismException when another experiment runs for the same agent.

public ValueTask<Experiment> StartAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The updated experiment.

StopAsync(string, string, CancellationToken)

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

Moves the experiment to ExperimentStatus.Stopped.

public ValueTask<Experiment> StopAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The experiment name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<Experiment>

The updated experiment.