GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(usage): skip unchanged Antigravity databases on repeat scans by derektrimm · Pull Request #13902 · pingdotgg/t3code

Conversation

@derektrimm

@derektrimm derektrimm commented Sep 27, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What Changed

Antigravity databases are decoded once and reused on later usage scans while the database and its -wal sidecar keep the same size, mtime and ctime. Aliases still merge across every database before the date window is applied, as before.

Why

Refs #13852. Every getUsageSummary decoded every Antigravity .db on the server thread, so a large history stalled the event loop for seconds on each request and the desktop showed the machine as reconnecting. The file cache the other providers use never applied to this reader.

The key includes the WAL because new rows land there while the main file keeps its size and mtime until a checkpoint. A key on the main file alone would hide new usage. ctime is included because it moves on any content write, even one that restores size and mtime.

On a synthetic corpus of 40 databases and 20,000 records, a repeat scan drops from about 150 ms to 7 ms, and the cache holds about 5 MB. The first scan after a server start still decodes everything; moving that read off the main thread, the second step in the triage, is not in this PR.

Verified with vp test run src/usage/ (114 passed), the server typecheck, and lint on the changed files. Each new test fails when the WAL or ctime is dropped from the key, or the cache is bypassed.

Checklist

  • This PR is small and focused
  • I explained what changed and why

Summary by CodeRabbit

  • Improvements
    • Antigravity usage scans reuse results while the underlying data remains unchanged, helping avoid unnecessary rereads. Results refresh when the data changes, including updates recorded in the database’s write-ahead log.
    • OpenCode usage is still checked live on each scan, so its results reflect the latest available data. The different refresh behavior helps balance efficient Antigravity scans with up-to-date OpenCode usage.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@derektrimm
fix(usage): skip unchanged Antigravity databases on repeat scans
a68589b
Every usage summary decoded every Antigravity conversation database again, blocking the server long enough for clients to drop the connection. Memoise each database's parsed candidates by the (size, mtime) of the file and its WAL sidecar, and keep merging aliases before the date filter.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 27, 2026
macroscopeapp[bot]
macroscopeapp Bot reviewed Sep 27, 2026
View reviewed changes
Comment thread apps/server/src/usage/UsageService.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@macroscopeapp

macroscopeapp Bot commented Sep 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — The change adds a process-level cache that conditionally skips Antigravity database decoding on repeat production usage scans while preserving WAL and rewrite detection through filesystem fingerprints. Its focused tests reduce risk, but the new gate changes when substantial usage-processing work occurs and merits human review.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
docs/internals/effect-services.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ad999758-d333-4c3b-b3b2-9e5508531f93
📥 Commits

Reviewing files that changed from the base of the PR and between c993d62 and f1246e3.

📒 Files selected for processing (1)
  • apps/server/src/usage/usageTranscriptReader.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Antigravity usage scans now reuse parsed database candidates when the database and WAL metadata match a cached snapshot. UsageService creates and passes the cache to the reader. Tests cover cache reuse, database changes, and WAL updates.

Changes

Antigravity usage database caching

Layer / File(s) Summary
Reader cache behavior
apps/server/src/usage/antigravityUsageReader.ts, apps/server/src/usage/usageTranscriptReader.test.ts
The reader accepts an optional cache keyed by canonical database path. It reuses parsed candidates when database and WAL size, mtime, and ctime match. Otherwise, it rereads the database and updates the cache. It removes entries for paths not visited. Tests cover cached results after a locked read fails, rewritten database contents, and WAL-only changes.
UsageService cache wiring
apps/server/src/usage/UsageService.ts
UsageService creates a cache and passes it to the Antigravity reader. Its documentation distinguishes OpenCode live database reads from Antigravity cache reuse.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: maria-rcks

Merge Risk: 🔵 Low · up to f1246

On filesystems with coarse timestamps, a rapid database rewrite can leave repeat scans reporting outdated usage. The risk is narrow and timing-dependent.

Architecture Summary

Architecture risk: 🔵 Low · up to f1246

The change affects 1 system.

Changed systems: apps/server

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — apps/server (service) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/usage/UsageService.ts: The comment now distinguishes OpenCode’s live database reads from Antigravity’s in-memory memoization, which applies while the database and WAL retain the same (size, mtime, ctime). It replaces the generic statement that SQLite readers query live databases.
  • observed — Modified behavior in apps/server/src/usage/UsageService.ts: The import now includes makeAntigravityUsageCache alongside readAntigravityUsage.
  • observed — Modified behavior in apps/server/src/usage/UsageService.ts: make now creates an Antigravity usage cache for the service instance.
  • observed — Modified behavior in apps/server/src/usage/UsageService.ts: The Antigravity reader call now receives the service’s cache as a third argument.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: skipping repeat reads of unchanged Antigravity databases.
Description check ✅ Passed The description explains the problem, change, and verification in detail under headings that differ from the template. It references issue #13852 but does not state maintainer approval or explain why …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rabesss rabesss mentioned this pull request Sep 28, 2026
Usage page shows $0 and the desktop app keeps reconnecting while getUsageSummary reads Antigravity history #13852
Closed
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
@derektrimm
fix(usage): include ctime in the Antigravity cache fingerprint
c993d62
A rewrite that restores size and mtime still moves ctime, so the cache no longer serves stale candidates in that case. The reuse test now proves a cache hit with an exclusive lock instead of a forged rewrite, and the forged rewrite gets its own test that expects a fresh read.
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 3, 2026
View reviewed changes
@derektrimm
test(usage): land the forged rewrite on a later timestamp tick
f1246e3
On kernels with coarse timestamps a write in the same tick as the cached read keeps the same ctime, so the test repeats the rewrite until ctime moves, as any real rewrite does.
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 4, 2026 23:31

Dismissing prior approval to re-evaluate f1246e3

@derektrimm

derektrimm commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Checked against current main after #15149: this merges cleanly, and the usage tests (145) and server typecheck pass on the merged tree. #15149 speeds up the transcript scan; readAntigravityUsage is still called without a cache on main, which is the part this covers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge juliusmarminge mentioned this pull request Oct 8, 2026
[Bug]: Usage counts most Antigravity calls three times (step, generation and retry copies are all added) #17071
Closed
2 tasks done
@t3dotgg t3dotgg mentioned this pull request Oct 8, 2026
fix(usage): repeat usage scans no longer decode unchanged Antigravity databases #17139
Merged
t3dotgg added a commit that referenced this pull request Oct 8, 2026
@t3dotgg @derektrimm @claude
fix(usage): repeat usage scans no longer decode unchanged Antigravity…
4d1f24b
… databases (#17139)

Takeover of #13902.

Co-authored-by: Derek Trimm <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@juliusmarminge

juliusmarminge commented Oct 8, 2026

Copy link
Copy Markdown
Member

Note

Grok responding on behalf of Julius.

Thanks @derektrimm! This landed via the takeover in #17139, rebased onto current main with your commits and authorship kept, so I'm closing this one as superseded.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge juliusmarminge closed this Oct 8, 2026
This was referenced Oct 9, 2026
fix(usage): unchanged Antigravity databases are not decoded again after a restart #17391
Closed
fix(usage): unchanged Antigravity databases are not decoded again after a restart #18973
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@macroscopeapp macroscopeapp[bot] macroscopeapp[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@derektrimm @juliusmarminge
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.