import { RolloutConfig, EvaluationContext, Variant, VariantId } from './types'; import { HashFunction } from './hash-function'; /** * Result of rollout evaluation. */ export interface RolloutResult { /** Whether the user is included in the rollout */ readonly included: boolean; /** The variant to serve */ readonly variantId?: VariantId; /** The percentage bucket the user falls into */ readonly bucket?: number; /** Current rollout percentage */ readonly percentage?: number; /** Current stage (for staged rollouts) */ readonly stage?: string; /** Current ring (for ring rollouts) */ readonly ring?: string; /** Whether user is in canary group */ readonly isCanary?: boolean; /** Experiment details */ readonly experiment?: { readonly experimentId: string; readonly allocationPercentage: number; }; } /** * Engine for evaluating percentage-based rollouts. */ export declare class PercentageRolloutEngine { private readonly hashFunction; private stickyBuckets; constructor(hashFunction?: HashFunction); /** * Evaluate a rollout configuration. */ evaluate(rollout: RolloutConfig, context: EvaluationContext, flagKey: string, variants: readonly Variant[]): RolloutResult; /** * Set a sticky bucket for a user/flag combination. */ setStickyBucket(flagKey: string, hashKey: string, bucket: number): void; /** * Clear sticky buckets. */ clearStickyBuckets(): void; /** * Get the bucket for a user/flag combination. */ getBucket(flagKey: string, hashKey: string, salt?: string): number; private evaluatePercentage; private evaluateScheduled; private getCurrentStage; private evaluateRing; private getRingPriority; private isInRing; private evaluateCanary; private evaluateExperiment; private getDefaultHashKey; private selectVariant; }