export type KbxExperimentRuntimeState = 'draft' | 'running' | 'paused' | 'rolled-back' | 'graduated' | 'completed'

export interface KbxExperimentAssignment {
  experimentId: string
  flagId: string
  screenId: string
  enrolled: boolean
  variant: string
  state: KbxExperimentRuntimeState
}

export interface KbxExperimentAssignmentsResponse { assignments: KbxExperimentAssignment[] }

export interface KbxExperimentVariantMetric {
  variant: string
  exposures: number
  taskCompletions: number
  interactionsPerTask?: number | null
  taskCompletionP95Ms?: number | null
  validationFailureRate?: number | null
}

export interface KbxExperimentOverviewRow {
  experimentId: string
  screenId: string
  state: KbxExperimentRuntimeState
  rolloutPercent: number
  killSwitch: boolean
  decision: 'inconclusive' | 'guardrail-breach' | 'candidate' | 'neutral' | 'rolled-back'
  variants: KbxExperimentVariantMetric[]
  updatedAt?: string | null
}

export interface KbxExperimentOverviewResponse { items: KbxExperimentOverviewRow[] }
export interface KbxExperimentRolloutRequest { rolloutPercent: number; state: 'running' | 'paused'; reason: string }
export interface KbxExperimentRollbackRequest { reason: string }
