1use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
7pub struct SymbolFact {
8 pub path: String,
9 pub name: String,
10 pub kind: String,
11 pub complexity: u32,
12 pub calls: Vec<String>,
13 pub start_byte: usize,
14 pub end_byte: usize,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
18pub struct FileFact {
19 pub snapshot_id: String,
20 pub path: String,
21 pub language: String,
22 pub bytes: u64,
23 pub loc: u32,
24 pub sloc: u32,
25 pub complexity_total: u32,
26 pub max_fn_complexity: u32,
27 pub symbol_count: u32,
28 pub import_count: u32,
29 pub fan_in: u32,
30 pub fan_out: u32,
31 pub churn_30d: u32,
32 pub churn_90d: u32,
33 pub authors_90d: u32,
34 pub last_changed_ms: Option<u64>,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
38pub struct RepoEdge {
39 pub from_path: String,
40 pub to_path: String,
41 pub kind: String,
42 pub weight: u32,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
46pub struct RepoSnapshotRecord {
47 pub id: String,
48 pub workspace: String,
49 pub head_commit: Option<String>,
50 pub dirty_fingerprint: String,
51 pub analyzer_version: String,
52 pub indexed_at_ms: u64,
53 pub dirty: bool,
54 pub graph_path: String,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
58pub struct ToolSpanView {
59 pub tool: String,
60 pub status: String,
61 pub lead_time_ms: Option<u64>,
62 pub tokens_in: Option<u32>,
63 pub tokens_out: Option<u32>,
64 pub reasoning_tokens: Option<u32>,
65 pub cost_usd_e6: Option<i64>,
66 pub paths: Vec<String>,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
70pub struct RankedFile {
71 pub path: String,
72 pub value: u64,
73 pub complexity_total: u32,
74 pub churn_30d: u32,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
78pub struct RankedTool {
79 pub tool: String,
80 pub calls: u64,
81 pub p50_ms: Option<u64>,
82 pub p95_ms: Option<u64>,
83 pub total_tokens: u64,
84 pub total_reasoning_tokens: u64,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
88pub struct MetricsReport {
89 pub snapshot: Option<RepoSnapshotRecord>,
90 pub hottest_files: Vec<RankedFile>,
91 pub most_changed_files: Vec<RankedFile>,
92 pub most_complex_files: Vec<RankedFile>,
93 pub highest_risk_files: Vec<RankedFile>,
94 pub slowest_tools: Vec<RankedTool>,
95 pub highest_token_tools: Vec<RankedTool>,
96 pub highest_reasoning_tools: Vec<RankedTool>,
97 pub agent_pain_hotspots: Vec<RankedFile>,
98}
99
100#[derive(Debug, Clone, Default, PartialEq, Eq)]
101pub struct FileHistory {
102 pub churn_30d: u32,
103 pub churn_90d: u32,
104 pub authors_90d: u32,
105 pub last_changed_ms: Option<u64>,
106}
107
108#[derive(Debug, Clone, Default, PartialEq, Eq)]
109pub struct RepoAnalysis {
110 pub path: String,
111 pub language: String,
112 pub bytes: u64,
113 pub loc: u32,
114 pub sloc: u32,
115 pub complexity_total: u32,
116 pub max_fn_complexity: u32,
117 pub imports: Vec<String>,
118 pub symbols: Vec<SymbolFact>,
119}