1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4pub struct Symbol {
5 pub symbol_id: String,
6 pub file_id: String,
7 pub path: String,
8 pub language: String,
9 pub name: String,
10 pub kind: String,
11 pub signature: Option<String>,
12 pub doc_comment: Option<String>,
13 pub visibility: Option<String>,
14 pub parent_symbol_id: Option<String>,
15 pub start_line: usize,
16 pub start_column: usize,
17 pub end_line: usize,
18 pub end_column: usize,
19 pub start_byte: usize,
20 pub end_byte: usize,
21 pub body_start_line: Option<usize>,
22 pub body_start_column: Option<usize>,
23 pub body_end_line: Option<usize>,
24 pub body_end_column: Option<usize>,
25 pub body_start_byte: Option<usize>,
26 pub body_end_byte: Option<usize>,
27 pub body_hash: Option<String>,
28 pub semantic_group: Option<String>,
29 pub is_test: bool,
30 pub test_container: bool,
31}
32
33impl Symbol {
34 pub fn hidden_body_line_count(&self) -> Option<usize> {
36 match (self.body_start_line, self.body_end_line) {
37 (Some(start), Some(end)) if end >= start => Some(end - start + 1),
38 _ => None,
39 }
40 }
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
44pub struct FileFact {
45 pub file_id: String,
46 pub path: String,
47 pub language: String,
48 pub content_hash: String,
49 pub content_bytes: i64,
50 pub line_count: Option<i64>,
51 pub indexed_at: String,
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
55pub struct ReferenceSite {
56 pub from_symbol_name: String,
57 pub from_symbol_id: String,
58 pub to_symbol_name: String,
59 pub kind: String,
60 pub path: String,
61 pub start_line: Option<usize>,
62 pub start_column: Option<usize>,
63 #[serde(default, skip_serializing_if = "Option::is_none")]
64 pub occurrences: Option<usize>,
65 #[serde(default, skip_serializing_if = "Option::is_none")]
67 pub target: Option<String>,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
71pub struct StructuralFact {
72 pub structural_fact_id: String,
73 pub path: String,
74 pub language: String,
75 pub pattern_id: String,
76 pub capture_name: String,
77 pub node_kind: String,
78 pub key: Option<String>,
79 pub metadata: Option<serde_json::Value>,
80 pub containing_symbol_name: Option<String>,
81 pub start_line: usize,
82 pub end_line: usize,
83 pub confidence: f64,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
87pub struct LiteralFact {
88 pub literal_id: String,
89 pub path: String,
90 pub literal_text: String,
91 pub kind: String,
92 pub carrier: Option<String>,
93 pub start_line: usize,
94 pub containing_symbol_name: Option<String>,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
98pub struct TypeFact {
99 pub type_fact_id: String,
100 pub symbol_id: String,
101 pub language: String,
102 pub resolved_type: String,
103 pub generic_params: Option<String>,
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
107pub struct ContextSlice {
108 pub target_symbol: Symbol,
109 pub target_body: String,
110 pub callee_signatures: Vec<String>,
111 pub related_types: Vec<String>,
112 pub related_tests: Vec<Symbol>,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
118pub struct SymbolSearchResult {
119 pub symbol: Symbol,
120 pub score: f64,
121 pub snippet: Option<String>,
122 #[serde(default, skip_serializing_if = "Option::is_none")]
123 pub explain: Option<SearchExplain>,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
131pub struct SearchExplain {
132 pub bm25: Option<f64>,
133 pub branches: Vec<String>,
134 pub name_tier: String,
135 pub name_strength: u32,
136 pub terms: Vec<(String, String, f64)>,
137 pub term_score: f64,
138 pub name_bonus: f64,
139 pub kind_prior: f64,
140 pub path_role: f64,
141 pub documentation: f64,
142 pub test_intent: f64,
143 #[serde(default)]
144 pub nested: f64,
145 pub word_weights: Vec<(String, f64)>,
146 pub candidates: usize,
147 pub rerank_us: u128,
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
151pub struct BlastRadiusResult {
152 pub seed_type: String,
153 pub seeds: Vec<String>,
154 pub likely_tests: Vec<TestTarget>,
155 pub impacted_symbols: Vec<ImpactedSymbol>,
156 pub likely_tests_truncated: bool,
157 pub impacted_symbols_truncated: bool,
158 #[serde(default)]
159 pub traversal_ceiling_reached: bool,
160 pub test_file_ceiling_reached: bool,
161 #[serde(default)]
163 pub limit_at_maximum: bool,
164 #[serde(default)]
166 pub likely_tests_found: usize,
167 #[serde(default)]
169 pub impacted_symbols_found: usize,
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
173pub struct TestTarget {
174 pub name: String,
175 pub path: String,
176 pub line: usize,
177 pub reason: String,
178}
179
180#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
181pub struct ImpactedSymbol {
182 pub name: String,
183 pub kind: String,
184 pub path: String,
185 pub line: usize,
186 pub depth: usize,
187}