Files
KArtSell.Aegis/docs/Design/kbx-foundation-v52-fe-operational-navigation-screen-anatomy/backend/Shared/Experiments/KbxExperimentAssignmentPolicy.cs
T
kjh2064 c41e5063b7 chore: remove kbx-foundation-v36 reference (superseded by v4 implementation)
Removed entire kbx-foundation-v36 directory as it's been replaced by
the new KBX Foundation v4 patterns implemented in this session:
- Registry-driven screen definitions
- Density-aware UI adapter components
- Feature module templates (ShadowRun, Models)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-12 01:39:58 +09:00

21 lines
999 B
C#

using System.Security.Cryptography;
using System.Text;
using Kbx.Shared.Experiments.Generated;
namespace Kbx.Shared.Experiments;
public static class KbxExperimentAssignmentPolicy
{
public static bool IsEnrolled(Guid tenantId,Guid userId,string experimentId,int rolloutPercent) =>
rolloutPercent>0 && Bucket(tenantId,userId,experimentId,"enroll") < rolloutPercent*100;
public static string ChooseVariant(Guid tenantId,Guid userId,KbxExperimentDefinition definition)
{
var point=Bucket(tenantId,userId,definition.Id,"variant")%100,cumulative=0;
foreach(var item in definition.Variants){cumulative+=item.Weight;if(point<cumulative)return item.Key;}
return "control";
}
private static int Bucket(Guid tenantId,Guid userId,string experimentId,string purpose)
{
var bytes=SHA256.HashData(Encoding.UTF8.GetBytes($"{tenantId:N}|{userId:N}|{experimentId}|{purpose}|kbx-v1"));
return (int)(BitConverter.ToUInt32(bytes,0)%10000);
}
}