export const XIAOBAO_PRISMA = 'XIAOBAO_PRISMA';
export const XIAOBAO_SUMMARY_REFRESH_JOB = 'xiaobao.summary.refresh';

export type XiaobaoRiskLevel = 'on_track' | 'attention' | 'at_risk' | 'likely_delayed' | 'blocked';

export interface RefreshXiaobaoRiskOptions {
  now?: Date;
}

export interface XiaobaoRiskSummaryPayload {
  versionId: string;
  versionName: string;
  productId?: string;
  productName?: string;
  projectId?: string | null;
  projectName?: string;
  expectedReleaseDate: string | null;
  riskScore: number;
  riskLevel: XiaobaoRiskLevel;
  confidence: number;
  forecastReleaseDate?: string;
  delayDays: number;
  remainingWorkHours: number;
  riskSignature: string;
  signals: {
    unfinishedCount: number;
    openBugCount: number;
    criticalBugCount: number;
    failedTestCount: number;
    blockedCount: number;
    silentRiskCount: number;
    daysToExpectedRelease?: number;
  };
  reasons: Array<{
    key: string;
    title: string;
    detail: string;
    severity: 'info' | 'warning' | 'danger';
    count?: number;
  }>;
  dailyEvidence: {
    todayDeliveries: unknown[];
    todayProgress: unknown[];
    todayCreations: unknown[];
    todayRisks: unknown[];
    progressNotes: unknown[];
    needsProgressItems: unknown[];
    recentActivityCount: number;
    totalActivityCount: number;
    todayActualHours: number;
    lastActivityAt?: string;
    silentRisks: unknown[];
  };
  currentSnapshot: {
    versionId: string;
    date: string;
    riskScore: number;
    riskLevel: XiaobaoRiskLevel;
    forecastReleaseDate?: string;
    openBugCount: number;
    criticalBugCount: number;
    failedTestCount: number;
    blockedCount: number;
    silentRiskCount: number;
    confidence: number;
    createdAt: string;
  };
}
