Skip to content

Commit 7f68f3b

Browse files
committed
fix(gemini): restrict default discovery roots, harden total aggregation, and tighten fixture schema
1 parent fe75641 commit 7f68f3b

3 files changed

Lines changed: 28 additions & 42 deletions

File tree

‎rust/adapters/gemini/src/loader.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ mod tests {
8484
let db_path = fixture.path("session-db.db");
8585
let connection = sqlite::open(&db_path).unwrap();
8686
connection
87-
.execute("CREATE TABLE gen_metadata (idx INTEGER PRIMARY KEY, data BLOB);")
87+
.execute("CREATE TABLE gen_metadata (idx INTEGER, data BLOB);")
8888
.unwrap();
8989

9090
// 1.4: tokens submessage (1.4.2 = 1000, 1.4.3 = 200, 1.4.5 = 500, 1.4.9 = 50)

‎rust/adapters/gemini/src/parser.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ pub(super) fn parse_sqlite_file(path: &Path) -> Result<Vec<GeminiUsageEvent>> {
301301
continue;
302302
}
303303
let thoughts = reasoning_tokens.max(visible_tokens.saturating_sub(output_tokens));
304+
let total_tokens = input_tokens
305+
.saturating_add(output_tokens)
306+
.saturating_add(cache_read_tokens)
307+
.saturating_add(thoughts);
304308
let event = build_event(
305309
Some(&model),
306310
&session_id,
@@ -311,7 +315,7 @@ pub(super) fn parse_sqlite_file(path: &Path) -> Result<Vec<GeminiUsageEvent>> {
311315
cached: cache_read_tokens,
312316
thoughts,
313317
tool: 0,
314-
total: Some(input_tokens + output_tokens + cache_read_tokens + thoughts),
318+
total: Some(total_tokens),
315319
},
316320
normalize_session_input,
317321
Some(format!("antigravity-gen-{idx}")),

‎rust/adapters/gemini/src/paths.rs‎

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,38 @@ pub(super) const ANTIGRAVITY_DATA_DIR_ENV: &str = "ANTIGRAVITY_DATA_DIR";
99
fn paths() -> Result<Vec<PathBuf>> {
1010
let mut paths = Vec::new();
1111
let mut seen = HashSet::new();
12-
if let Ok(env_paths) = env::var(GEMINI_DATA_DIR_ENV) {
13-
for raw in env_paths
14-
.split(',')
15-
.map(str::trim)
16-
.filter(|path| !path.is_empty())
17-
{
18-
let path = PathBuf::from(raw);
19-
if path.is_dir() && seen.insert(path.clone()) {
20-
paths.push(path);
21-
}
22-
}
23-
return Ok(paths);
24-
}
2512

26-
if let Ok(env_paths) = env::var(ANTIGRAVITY_DATA_DIR_ENV) {
27-
for raw in env_paths
28-
.split(',')
29-
.map(str::trim)
30-
.filter(|path| !path.is_empty())
31-
{
32-
let path = PathBuf::from(raw);
33-
if path.is_dir() && seen.insert(path.clone()) {
34-
paths.push(path);
13+
let mut env_override = false;
14+
for env_var in [GEMINI_DATA_DIR_ENV, ANTIGRAVITY_DATA_DIR_ENV] {
15+
if let Ok(env_paths) = env::var(env_var) {
16+
env_override = true;
17+
for raw in env_paths
18+
.split(',')
19+
.map(str::trim)
20+
.filter(|path| !path.is_empty())
21+
{
22+
let path = PathBuf::from(raw);
23+
if path.is_dir() && seen.insert(path.clone()) {
24+
paths.push(path);
25+
}
3526
}
3627
}
3728
}
29+
if env_override {
30+
return Ok(paths);
31+
}
3832

3933
if let Some(home) = crate::home::home_dir() {
4034
let path = home.join(".gemini").join("tmp");
4135
if path.is_dir() && seen.insert(path.clone()) {
4236
paths.push(path);
4337
}
44-
let antigravity_dirs = [
45-
home.join(".gemini")
46-
.join("antigravity")
47-
.join("conversations"),
48-
home.join(".gemini")
49-
.join("antigravity-cli")
50-
.join("conversations"),
51-
home.join(".gemini")
52-
.join("antigravity-ide")
53-
.join("conversations"),
54-
home.join(".gemini")
55-
.join("antigravity-backup")
56-
.join("conversations"),
57-
];
58-
for dir in antigravity_dirs {
59-
if dir.is_dir() && seen.insert(dir.clone()) {
60-
paths.push(dir);
61-
}
38+
let antigravity_dir = home
39+
.join(".gemini")
40+
.join("antigravity")
41+
.join("conversations");
42+
if antigravity_dir.is_dir() && seen.insert(antigravity_dir.clone()) {
43+
paths.push(antigravity_dir);
6244
}
6345
}
6446
Ok(paths)

0 commit comments

Comments
 (0)