export type HealthStatus = 'healthy' | 'watch' | 'quarantined';
export type Severity = 'info' | 'warning' | 'critical' | 'success';

export interface Summary {
  clients: number;
  activeClients: number;
  specFunctions: number;
  implementations: number;
  possibleCompositions: number;
  activeCompositions: number;
  telemetryEvents: number;
  populationFailureRate: number;
  previousFailureRate: number;
}

export interface Composition {
  id: string;
  label: string;
  clients: number;
  share: number;
  failureRate: number;
  implementations: string[];
}

export interface Implementation {
  id: string;
  releaseId: number;
  specFunction: string;
  variant: string;
  variantName?: string;
  experimental?: boolean;
  sourceUrl?: string;
  clients: number;
  executions: number;
  failures: number;
  failureRate: number;
  relativeRisk: number;
  confidence: number;
  status: HealthStatus;
}

export interface Interaction {
  first: string;
  second: string;
  clients: number;
  observedFailureRate: number;
  expectedFailureRate: number;
  lift: number;
  confidence: number;
}

export interface Quarantine {
  implementationId: string;
  variant: string;
  specFunction: string;
  quarantinedAt: string;
  reason: string;
  affectedClients: number;
  recomposedClients: number;
  beforeFailureRate: number;
  afterFailureRate: number;
  afterExecutions: number;
}

export interface TelemetryEvent {
  id: string;
  timestamp: string;
  kind: string;
  severity: Severity;
  clientId: string;
  implementationId: string;
  specFunction: string;
  message: string;
  recentCalls: string[];
}

export interface TrendPoint {
  label: string;
  failureRate: number;
  events: number;
}

export interface HealthStage {
  label: string;
  implementationId?: string;
  healthyRate: number;
  executions: number;
}

export interface DashboardData {
  generatedAt: string;
  release: { name: string; version: string; status: string; repositoryUrl?: string; artifactUrl?: string };
  summary: Summary;
  implementationsPerFunction: Array<{ name: string; count: number }>;
  compositions: Composition[];
  implementations: Implementation[];
  interactions: Interaction[];
  quarantines: Quarantine[];
  healthSequence: HealthStage[];
  telemetry: TelemetryEvent[];
  trend: TrendPoint[];
}
