export interface TestHistorySummary {
  firstSeenAt: string | null;
  lastSeenAt: string | null;
  lastRunAt: string | null;
  runCount: number;
  passCount: number;
  failCount: number;
  skipCount: number;
  avgDurationMs: number;
  lastStatus: "passed" | "failed" | "skipped" | "not_run" | null;
}

export interface TestHistoryEntry extends TestHistorySummary {
  id: string;
  path: string;
  service: string;
  suiteName: string;
  selectionType: string;
  framework: string;
  notRunCount: number;
  durationCount: number;
}

export interface TestHistoryDocument {
  version: number;
  tests: Record<string, TestHistoryEntry>;
}

export declare function historyFilePath(productDir: string): string;
export declare function createEmptyHistory(): TestHistoryDocument;
export declare function loadHistory(productDir: string): TestHistoryDocument;
export declare function saveHistory(productDir: string, history: TestHistoryDocument): void;
export declare function updateHistoryFromRunArtifact(
  history: TestHistoryDocument,
  runArtifact: unknown,
  recordedAt?: string | null
): TestHistoryDocument;
export declare function summarizeHistoryForFiles(
  history: TestHistoryDocument,
  files?: Array<{ id: string; service: string; selectionType: string; path: string }>
): Map<string, TestHistorySummary>;
export declare function buildHistoryTestId(
  serviceName: string,
  selectionType: string,
  filePath: string
): string;
