import type { AnalyticsSource } from "./sources.js";

/**
 * Single source of truth for the projection version of every adapter. It is written to
 * `source_files.adapter_version` after a successful import, recorded in `scan_runs.metadata_json`
 * and reported by status/diagnostics. Bump a source's version whenever its normalization changes
 * (classification, dedupe, token mapping, ...): the next scan re-imports that source's unchanged
 * files once, so already-imported data is corrected without deleting the database.
 */
export const ADAPTER_VERSIONS: Readonly<Record<AnalyticsSource, string>> = Object.freeze({
  // 0.2.0: session_meta-based main/subagent classification, originator surface, fork-context owner.
  // 0.2.1: repeated token_count snapshots (unchanged cumulative total) and usage-less snapshots ignored.
  codex: "0.2.1",
  // 0.2.0: VS Code chatSessions operation-log JSONL replay, result.usage tokens, per-request timestamps.
  copilot: "0.2.0",
  hook_log: "0.1.0",
  // 0.2.0: streaming JSONL, logical-message dedupe, tool results are not user messages, stale projections removed.
  claude: "0.2.0-postmvp",
  // 0.2.0: subagent composers classified from composerHeaders; dashboard usage-export rows preserved.
  cursor: "0.2.0-postmvp-unofficial-schema",
  // 0.2.0: usage from conversations/<id>.db generation metadata; transcript re-import keeps it.
  antigravity: "0.2.0-postmvp-unofficial-schema"
});

/**
 * Versions that produced rows before `source_files.adapter_version` existed (the values the
 * scanner recorded in scan_runs.metadata_json). Migration 17 backfills them, so only sources whose
 * adapter changed since then are re-imported.
 */
export const LEGACY_ADAPTER_VERSIONS: Readonly<Record<AnalyticsSource, string>> = Object.freeze({
  codex: "0.1.0",
  copilot: "0.1.0",
  hook_log: "0.1.0",
  claude: "0.1.0-postmvp",
  cursor: "0.1.0-postmvp-unofficial-schema",
  antigravity: "0.1.0-postmvp-unofficial-schema"
});
