fix(antigravity): stamp mtime fallback at emission, tighten path classification#612
fix(antigravity): stamp mtime fallback at emission, tighten path classification#612Battiatus wants to merge 2 commits into
Conversation
CodeBurn previously only detected Antigravity CLI usage (.pb files under .gemini/antigravity/). Antigravity IDE on Windows stores session state in VSCode-style storage at %APPDATA%\Antigravity IDE\User\globalStorage\state.vscdb, which was not detected. Add support for reading Antigravity IDE sessions from the VSCode-style storage: - Extend CONVERSATION_ROOTS to include APPDATA Antigravity IDE path - Refine path classification to properly identify IDE vs CLI sessions - Handle missing per-call timestamps by stamping file mtime as fallback - Bump CACHE_VERSION to 4 for cache invalidation Fixes: CodeBurn reports zero usage when Antigravity IDE is actively used.
ozymandiashh
left a comment
There was a problem hiding this comment.
Thanks for this — the underlying problem it targets (SQLite gen_metadata calls with no per-call timestamp being silently dropped by the date-range filters) is real and worth fixing. A few things to resolve before it can merge:
1. Scope/title is stale vs main. Antigravity IDE discovery already landed in #418 (35a8518): ~/.gemini/antigravity-ide/conversations (+ implicit) are in CONVERSATION_ROOTS on main today. This PR does not add a new storage root, so "add support for Antigravity IDE storage" / "previously only detected Antigravity CLI" no longer describe the change. Please retitle to what it actually does (timestamp fallback + path classification).
2. The new APPDATA classifier branch is unreachable. antigravityAppDataDirFromSourcePath's if (lower.includes('/antigravity ide/')) (src/providers/antigravity.ts:471) can't fire in normal operation: discoverAntigravitySessionSources only walks the ~/.gemini/... roots, so no discovered source.path is ever an APPDATA path — and your own doc note says the %APPDATA%\...\state.vscdb DB holds trajectory metadata, "not token usage". As written it is dead code. Either wire APPDATA discovery for real, or drop the branch.
3. If kept, that classifier misroutes a real case. It is a broad substring match checked after the .gemini/antigravity-{ide,cli}/ cases, so a base-app path under a folder literally named "Antigravity IDE" — e.g. C:\Users\Antigravity IDE\.gemini\antigravity\conversations\x.db — classifies as antigravity-ide, and detectServer then targets the wrong server. Guard the base path first: if (lower.includes('/.gemini/antigravity/')) return 'antigravity' before the APPDATA line. No test covers this; the added test only checks the .gemini/antigravity-cli/ precedence case.
4. mtime-as-timestamp misattributes cost across date ranges. stampFallbackTimestamp assigns the same new Date(s.mtimeMs) to every timeless call and persists it into the cache. Consequences: (a) an entire multi-turn session's cost buckets onto the day the .db was last written, so today/week/month views are wrong for older sessions; (b) any later file rewrite shifts all historical calls forward to the new mtime. Antigravity already exposes real per-entry times (RPC chatStartMetadata.createdAt, and the state.vscdb trajectory metadata you documented), so prefer those over a shared file mtime. At minimum, don't persist a synthesized mtime into the cache, so a re-write can't retro-date history.
CI is green and types are clean, so none of this is blocking on CI — but 2-4 are correctness issues. Happy to re-review once addressed.
…sification - Apply the mtime fallback to a copy at emission instead of mutating and persisting it into the cache, so a later file rewrite can't retro-date a session's history to the new mtime. SQLite gen_metadata rows have no real per-call time; the RPC path still uses chatStartMetadata.createdAt. - Drop the unreachable APPDATA classifier branch (discovery only walks the ~/.gemini roots; APPDATA state.vscdb holds no token usage). This also removes the misroute of base-antigravity paths under an "Antigravity IDE" profile dir. - Bump CACHE_VERSION to invalidate caches that persisted a synthesized mtime.
|
Good catches. All three are fixed and pushed. For 2 and 3 I just deleted the APPDATA branch outright. Discovery never walks anything outside On 4 — yeah, persisting the mtime was the actual bug. Now the fallback is only applied to a copy right before the call is yielded, and the cached entry keeps its empty timestamp, so a rewrite can't drag old calls forward. I kept the mtime as the fallback itself since the SQLite rows genuinely have no per-call time (the RPC path already uses createdAt where it has one). Bumped the cache version so anything that already stored a synthesized time gets dropped. I also renamed the PR. Thanks |
|
Thanks — points 2 and 3 are fixed, but point 4 is still merge-blocking.
On a source fingerprint change, Please add an integration test through the generic parser/cache covering:
Existing deduplication keys must retain a real or stable timestamp across rewrites. Before falling back to mtime, please decode The PR description is also still stale: it says this change adds APPDATA / |
Summary
%APPDATA%\Antigravity IDE\User\globalStorage\state.vscdbResolves: CodeBurn reporting zero usage when Antigravity IDE is actively used
Issue id: #411 (comment)
Changes
antigravityAppDataDirFromSourcePath()to classify IDE dirs; addstampFallbackTimestamp()helper for missing timestamps across all emission paths; bump CACHE_VERSION to 4withTempAntigravityHome(); add coverage for IDE path detection and timestamp fallbackTest Plan