namespace Kbx.Shared.Experiments;
// Schedule hourly at most. This is an operational safety net, not a statistical significance engine.
public sealed class KbxExperimentGuardrailJob(KbxExperimentOverviewQuery query,KbxExperimentRuntimeStore store)
{
    public async Task ExecuteAsync(Guid tenantId,CancellationToken ct)
    {
        var overview=await query.ExecuteAsync(tenantId,ct);
        foreach(var item in overview.Items.Where(x=>x.State=="running"&&x.Decision=="guardrail-breach"))
            await store.RollbackAsync(tenantId,Guid.Empty,item.ExperimentId,"automatic guardrail rollback",null,ct);
    }
}
