Skip to content

Architecture & Internals

abhayhiwse-hub edited this page Sep 7, 2026 · 1 revision

Architecture & Technical Internals

Antigravity Usage Intelligence is engineered to be lightweight, zero-overhead, and privacy-preserving.

flowchart TD
    subgraph Local Storage [Local Disk / Ledgers]
        A["Antigravity SQLite Ledgers<br/>(~/.gemini/antigravity/conversations/*.db)"]
        B["Local Language Server<br/>(language_server_windows_x64.exe)"]
    end

    subgraph Telemetry Engine [Usage Intelligence Core]
        C["Python Telemetry Engine (collector.py)<br/>• Read-Only WAL Mode (?mode=ro&immutable=1)<br/>• Non-blocking Protobuf Parser<br/>• Atomic Incremental Cache (<80ms)"]
        D["Live Quota Detector (src/quota_detector.js)<br/>• Connect-RPC over HTTPS Loopback<br/>• CSRF Protected Local IPC"]
    end

    subgraph Extension Host [VS Code / Antigravity IDE]
        E["Extension Backend (extension.js)<br/>• Status Bar Item<br/>• Multi-View Controller"]
        F["Interactive Webview (src/ui/dashboard.html)<br/>• GitHub-Grade Heatmap<br/>• Dual Model Radial Gauges<br/>• Session Drawer & Search"]
    end

    A -->|Safe Read-Only WAL| C
    B -->|Connect-RPC HTTPS| D
    C -->|JSON Payload| E
    D -->|Live Quota Sync| E
    E -->|CSP & Nonce IPC| F
Loading

🔒 1. Zero-Contention SQLite WAL Engine (collector.py)

Google Antigravity stores active conversation steps in SQLite databases under ~/.gemini/antigravity/conversations/. To prevent database locks, schema corruption, or query contention while active AI pairing sessions are running, collector.py enforces three safeguards:

  1. URI Read-Only Parameter:
    sqlite3.connect(f"file:{db_path}?mode=ro&immutable=1", uri=True)
  2. Query-Only PRAGMA:
    PRAGMA query_only = ON;
  3. WAL-Safe Journal Mode Check: Never attempts to write temporary rollbacks or checkpoint the WAL file.

🌐 2. Local Language Server Connect-RPC Client (src/quota_detector.js)

Instead of guessing remaining quotas based on arbitrary heuristics, the extension connects directly to Antigravity's local language server process (language_server_windows_x64.exe):

  • Process Discovery: Discovers the running server port and command-line arguments using local OS process tables.
  • CSRF Protection: Extracts the internal ephemeral CSRF token generated during IDE startup.
  • Loopback HTTPS: Issues Connect-RPC POST requests to:
    POST https://127.0.0.1:<PORT>/exa.language_server_pb.LanguageServerService/GetUserStatus
    with headers:
    Content-Type: application/json
    X-Csrf-Token: <CSRF_TOKEN>
  • Payload Unpacking: Reads userStatus.tier, userStatus.quotaPools, and userStatus.resetTime without sending any personal data or file contents.

⚡ 3. Atomic Incremental Cache

Scanning thousands of historical conversation sessions on every UI render would introduce lag. Antigravity Usage Intelligence utilizes a derived-stats caching strategy:

  • Cache file: ~/.gemini/antigravity/antigravity_stats_cache.json.
  • Only databases whose file modification timestamps (mtime) have changed since the last scan are re-parsed.
  • Unmodified databases are served instantly from the cached index.
  • Typical cold run: ~600ms.
  • Typical warm run: < 80ms.

🛡️ 4. Privacy & Security Architecture

Boundary Policy Implementation
Outbound Network Zero Internet Access No HTTP/HTTPS calls outside 127.0.0.1
Code & Secrets Zero Extraction Prompts, files, code diffs, and API keys are never parsed or cached
Telemetry Beacons Zero External Logging No Google Analytics, no telemetry pings, no cloud tracking
Local Permissions Read-Only Local Filesystem Only reads Antigravity session metadata