Skip to main content

covy_core/
testmap.rs

1use std::collections::{BTreeMap, BTreeSet};
2
3#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
4pub struct TestMapMetadata {
5    pub schema_version: u16,
6    pub path_norm_version: u16,
7    pub repo_root_id: Option<String>,
8    pub generated_at: u64,
9    pub granularity: String,
10    #[serde(default)]
11    pub commit_sha: Option<String>,
12    #[serde(default)]
13    pub created_at: Option<u64>,
14    #[serde(default)]
15    pub toolchain_fingerprint: Option<String>,
16}
17
18impl Default for TestMapMetadata {
19    fn default() -> Self {
20        Self {
21            schema_version: 2,
22            path_norm_version: 1,
23            repo_root_id: None,
24            generated_at: 0,
25            granularity: "file".to_string(),
26            commit_sha: None,
27            created_at: None,
28            toolchain_fingerprint: None,
29        }
30    }
31}
32
33#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Default)]
34pub struct TestMapIndex {
35    pub metadata: TestMapMetadata,
36    pub test_language: BTreeMap<String, String>,
37    /// Legacy index used by pre-v2 impact planners (file-level only).
38    pub test_to_files: BTreeMap<String, BTreeSet<String>>,
39    /// Legacy inverse index used by pre-v2 impact planners (file-level only).
40    pub file_to_tests: BTreeMap<String, BTreeSet<String>>,
41    /// V2 canonical test id list (index -> test id).
42    #[serde(default)]
43    pub tests: Vec<String>,
44    /// V2 canonical file key list (index -> repo-relative path).
45    #[serde(default)]
46    pub file_index: Vec<String>,
47    /// V2 coverage matrix: test_idx -> file_idx -> changed line numbers.
48    #[serde(default)]
49    pub coverage: Vec<Vec<Vec<u32>>>,
50}
51
52#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Default)]
53pub struct TestTimingHistory {
54    pub generated_at: u64,
55    pub duration_ms: BTreeMap<String, u64>,
56    pub sample_count: BTreeMap<String, u32>,
57    pub last_seen: BTreeMap<String, u64>,
58}