AuditingExperimentStore
AgentPrism.Core.dllWraps IExperimentStore in a decorator that writes an audit trail.
public sealed class AuditingExperimentStore : IExperimentStore, IAuditDecoratedInheritance
Section titled “Inheritance”object ← AuditingExperimentStore
Implements
Section titled “Implements”IExperimentStore, IAuditDecorated
Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Constructors
Section titled “Constructors”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)Parameters
Section titled “Parameters”inner IExperimentStore
auditLog IAuditLog
tenantContext ITenantContext
actorResolver IAuditActorResolver
logger ILogger<AuditingExperimentStore>
Properties
Section titled “Properties”AuditedInner
Section titled “ AuditedInner”Gets the real store instance the decorator wraps.
public object AuditedInner { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”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)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”The updated experiment.
Remarks
Section titled “Remarks”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)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The experiment name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The experiment name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
agentName string
The agent name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The running experiment, or null when none exists.
ListAsync(string, CancellationToken)
Section titled “ ListAsync(string, CancellationToken)”Lists all experiments for a tenant by name.
public ValueTask<IReadOnlyList<Experiment>> ListAsync(string tenantId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<Experiment>>
The running experiments that define a canary policy.
Remarks
Section titled “Remarks”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)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”The updated experiment.
Remarks
Section titled “Remarks”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.
SaveAsync(Experiment, CancellationToken)
Section titled “ SaveAsync(Experiment, CancellationToken)”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)Parameters
Section titled “Parameters”experiment Experiment
The experiment to save.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”The updated experiment.
Remarks
Section titled “Remarks”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)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The experiment name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”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)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The experiment name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The updated experiment.