/**
 * Task complexity levels for budget allocation
 */
export type TaskComplexity = "low" | "medium" | "high" | "critical";

/**
 * Token budget data structure
 */
export interface TokenBudgetData {
  id: string;
  taskId: string;
  workspaceId: string;
  agentId: string;
  allocatedTokens: number;
  estimatedComplexity: TaskComplexity;
  inputTokensUsed: number;
  outputTokensUsed: number;
  totalTokensUsed: number;
  estimatedCost: number | null;
  startedAt: Date;
  lastUpdatedAt: Date;
  completedAt: Date | null;
  budgetUtilization: number | null;
  suspiciousPattern: boolean;
  suspiciousReason: string | null;
}

/**
 * Budget analysis result
 */
export interface BudgetAnalysis {
  taskId: string;
  allocatedTokens: number;
  usedTokens: number;
  remainingTokens: number;
  utilizationPercentage: number;
  suspiciousPattern: boolean;
  suspiciousReason: string | null;
  recommendation: "accept" | "continue" | "review";
}

/**
 * Suspicious pattern detection result
 */
export interface SuspiciousPattern {
  triggered: boolean;
  reason?: string;
  severity: "low" | "medium" | "high";
  recommendation: "accept" | "continue" | "review";
}

/**
 * Complexity-based budget allocation
 */
export const COMPLEXITY_BUDGETS: Record<TaskComplexity, number> = {
  low: 50000, // Simple fixes, typos
  medium: 150000, // Standard features
  high: 350000, // Complex features
  critical: 750000, // Major refactoring
};

/**
 * Token budget thresholds for suspicious pattern detection
 */
export const BUDGET_THRESHOLDS = {
  SUSPICIOUS_REMAINING: 0.2, // >20% budget remaining + gates failing = suspicious
  VERY_LOW_UTILIZATION: 0.1, // <10% utilization = suspicious
  VERY_HIGH_UTILIZATION: 0.95, // >95% utilization but gates failing = suspicious
};
