feat(antigravity): estimate local history costs from models.dev prices - #3412
feat(antigravity): estimate local history costs from models.dev prices#3412WeGoToMars wants to merge 2 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
0762861 to
c14ff72
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0762861b7c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Codex review: blocked before merge. Reviewed September 4, 2026, 3:26 AM ET / 07:26 UTC. ClawSweeper reviewWhat this changesAdds public-price estimates to Antigravity’s local token history, updates CLI and native disclosures, preserves compatible Codex caches, and makes Linux pricing-cache replacement atomic. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 6 items remain This remains useful work absent from main and v0.56.4. The Linux replacement and Codex cache fixes are present, but all three latest findings remain unresolved. Priority: P2 Review scores
Verification
How this fits togetherCodexBar reads local Antigravity history and turns recorded model usage into daily summaries. This change combines those records with cached public prices before presenting costs in the CLI and native app. flowchart TD
A[Local SQLite or JSONL history] --> B[Validated token records]
C[Public pricing catalog] --> D[Cached prices]
D --> E{Model has a price?}
B --> E
E -->|Yes| F[Estimated cost and tokens]
E -->|No| G[Tokens with unpriced coverage]
F --> H[CLI and native summaries]
G --> H
Decision needed
Why: The contributor explicitly requests this decision; matching Codex and Claude policy does not establish permission to change Antigravity’s existing contract. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep ordinary history reads cache-only with an explicit pricing-refresh action, and make native summaries distinguish genuine estimates, unpriced history, and partial totals. Do we have a high-confidence way to reproduce the issue? Yes at source level: a missing or stale catalog, entirely unpriced history with no requests today, and mixed priced/unpriced requests expose the three remaining PR findings. Runtime reproduction was not executed during this read-only review. Is this the best way to solve the issue? No as submitted: reusing the existing catalog and pricing arithmetic is appropriate, but the network default needs approval and native disclosures need focused repairs. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 392310c66548. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Codex-subscription behavior for Antigravity local token history: local usage x public API prices, labeled API-equivalent estimate (not billed). Reasoning bills at output rates on the SQLite path; unknown models stay cost-less with tokens intact; provenance flips to listPriceEstimate only when costs exist. Mixed priced/unpriced windows disclose coverage; menu estimate hints render only when dollar figures exist. Related to steipete#53; follows steipete#2181, steipete#3001.
c14ff72 to
f4a122f
Compare
|
@clawsweeper re-review Pushed a single squashed commit addressing the findings: POSIX rename(2) Linux replacement with concurrency coverage, docs disambiguation (history scanning vs catalog refresh, Codex/Claude parity noted for the offline-policy decision), redacted live-history proof at the final head, and the Swift 6.3.3 type-check fix. Full suite green locally (1005/84 first-pass). |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed the remaining contributor-side compatibility finding at aab2de5. The remaining P1 is a maintainer policy decision: should Antigravity use the same automatic models.dev pricing refresh as Codex and Claude? The refresh fetches only the public pricing catalog. Keeping the shared behavior also allows Antigravity-only users to receive estimates without relying on another provider to populate the catalog. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
I'm not even getting token counts for AGY, anything specific needs to be done for this to work? |
Token counts support was merged in this PR: #3403 |
|
@steipete can you take a look at this PR? |
Extract the existing cache replacement defect identified in #3412 while leaving its Antigravity feature scope separate. Replace the redundant temporary-file swap with one atomic write and preserve successful-save memo invalidation. Co-authored-by: WeGoToMars <profigor7@gmail.com>
|
The shared pricing-cache replacement bug identified here is now fixed on main in #3444 (559bfc8). Thanks @WeGoToMars for surfacing it. The isolated fix uses one atomic destination write on both platforms, removing seven production lines. On Linux with Swift 6.3.3, the old code failed on the second save and left the catalog missing; the replacement passed 100 saves with disk and memo reads checked after each. The portable regression, all 1,025 local test selections, and all nine CI checks passed. One unrelated local RPC teardown timing failure passed on its group retry. This PR remains open for its Antigravity estimation and networking-policy scope. Its separate Linux cache-replacement branch can be dropped when rebasing onto main. |
…#3462) Antigravity bookkeeping rows without a step UUID caused the entire local history provider to be withheld as incomplete. Permit those rows after charging their row and byte budgets, while keeping malformed data and exhausted budgets as hard failures. A lone identified timestamp cannot stand for every occurrence of a reused UUID when unidentified rows are present. Rows without UUIDs can still carry bot identity. Record that evidence before skipping UUID positioning: a duplicate bot ID with unknown UUID permanently invalidates exact and positional matches, regardless of scan order, matching timestamps, or absent timestamps. This addresses the review finding on the original revision. Keep ambiguous positional slots intact so later timestamps never move into them. Share the identical step-occurrence structs, remove an unused counts projection, and apply positional ambiguity during timestamp selection. The final PR reduces production code by four lines. Token counts, pricing, credentials, discovery roots, and stored data remain unchanged. Changelog and documentation are updated; thanks @urda. Maintainer validation: six synthetic duplicate-bot combinations failed 18 assertions on the original PR and pass after repair. All 406 focused Antigravity tests across 34 suites pass, including harmless bookkeeping, reused UUIDs, embedded timestamps, malformed rows, and budgets. `make check` passes and independent review is clean. The full `make test` suite passed all 1,028 selections across 86 groups without retries. The main integration preserves the tested Antigravity source, tests, and documentation byte-for-byte; integration `make check` also passes. Exact-head CI must pass before merge. Contributor live evidence, collected on the original proposal: @urda compared the shipped 0.56.6 CLI and a rebuilt CLI against the same 211 stable local session databases from agy 1.1.27, using read-only scratch copies with WAL sidecars. Complete coverage increased from 208 to 211; the three recovered sessions contained 80,067, 48,183, and 5,299,395 tokens. Removing UUID-less bookkeeping rows from copies also made the shipped CLI return complete coverage, isolating the original cause. One previously passing session's output, excluding updatedAt, matched byte-for-byte. Three actively written sessions were excluded because both binaries reported them incomplete until checkpointing. This is contributor-reported live evidence; the maintainer's final ambiguity repair uses synthetic native SQLite fixtures. This builds on #3266, #3396, and #3403. It is distinct from #3412's cost-estimation changes. Earlier proposal #3451 remains related; no unrelated issue is claimed resolved. Co-authored-by: Peter Urda <peter.urda@gmail.com>
Summary
This PR adds estimated dollar costs to Antigravity's existing local token history.
The estimates use public API prices from models.dev. They are shown as API-equivalent estimates, not as billed spend or subscription value.
How it works
CodexBar continues to read Antigravity token history from the same local SQLite and JSONL files. This PR does not change history discovery, token counting, timestamps, credentials, or account attribution.
For each recorded model:
gpt-oss-120buses OpenAI pricing.When a period contains both priced and unpriced requests, CodexBar shows the coverage explicitly. For example:
Dollar-related labels and explanations appear only when at least one cost can be estimated. Completely unpriced history continues to be presented as token history.
Pricing catalog and network behavior
Prices come from CodexBar's on-disk models.dev catalog.
The current implementation follows the existing Codex and Claude pricing-cache policy: it uses a fresh cached catalog when available and may refresh models.dev when the catalog is stale or missing. A failed refresh keeps the existing catalog.
This changes Antigravity's previous fully local behavior and needs a maintainer decision:
The local history files themselves are never uploaded or modified.
Reliability
On Linux, catalog updates now use a same-directory atomic rename(2). Readers therefore see either the previous complete catalog or the new complete catalog, never a missing or partially written file.
The implementation follows the existing CostUsageClaudeCache pattern. Tests cover concurrent readers and writers and verify that no temporary or backup files remain.
User-facing changes
Testing
Run on macOS at final head aab2de5:
GitHub CI additionally covers Linux x64, Linux arm64, and musl.
Proof
Synthetic fixture
Tested at final head aab2de5 with one supported model and one unsupported model.
$ shasum -a 256 session-a.db
e2ced86ffaf5c286f303758929788832c38260fbd1db8b3eee8499eadfa5b733 session-a.db
$ HOME="$TMP/home" XDG_CACHE_HOME="$TMP/cache"
CodexBarCLI cost --provider antigravity --format text
Antigravity API-equivalent estimate (not billed)
Today: $0.00 · 0 tokens
Last 30 days: $0.00 · 1.9K tokens
Coverage: 1 estimated · 1 unpriced
Not a subscription bill or plan value · local usage × public API prices
$ shasum -a 256 session-a.db
e2ced86ffaf5c286f303758929788832c38260fbd1db8b3eee8499eadfa5b733 session-a.db
The matching hashes confirm that the history database was not modified.
Redacted local-history run
Tested with a copy of real Antigravity history at final head aab2de5:
{ "provider": "antigravity", "provenance": "listPriceEstimate", "historyCoverageIsEstablished": true, "coverage": { "estimated": 5, "unpriced": 0, "priced": 0, "unmetered": 0 }, "last30DaysTokens": "<redacted>", "last30DaysCostUSD": "<redacted>" }Sensitive token counts and paths are redacted. The visible output confirms the estimate label, coverage reporting, and successful handling of local history. The copied input databases hashed identically before and after the run.
Related work
Related to #53. Builds on #2181 and #3001.