Repository navigation
Add observed quota API-equivalent estimates - #13
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a process-local “observed standard API‑equivalent” estimator to Quota views by correlating stable local rollout accounting with quota percentage movement, and extends pricing provenance (retrieval date + official hyperlink) to all pricing-bearing Quota/Benchmark footers. It also updates embedded standard API pricing (including long-context tiers) and bumps the maintained source version to v0.7.1.
Changes:
- Introduce a quota API‑equivalent observation pipeline (anchors, evidence retention, confidence rules) and render responsive “API‑EQ” lines on Quota meters.
- Add account identity fingerprinting (process-local, non-persisted) to isolate observations per account and fail closed when identity is unavailable.
- Update standard API pricing constants, long-context pricing behavior, demos, tests, and docs; bump version to v0.7.1.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the observed quota API‑equivalent estimator, safeguards/privacy posture, pricing provenance display, and version bump. |
| main.go | Enhances demo fetcher to simulate API‑EQ usage and quota movement with a stable accounting bracket. |
| main_test.go | Updates version expectation and adds demo bracket stability / API‑EQ advancement assertions. |
| internal/version/version.go | Bumps maintained fallback version to 0.7.1. |
| internal/version/version_test.go | Updates maintained fallback version test to 0.7.1. |
| internal/ui/view.go | Injects quota “insights” meters and shows pricing provenance footer on Quota + Benchmark views. |
| internal/ui/view_test.go | Expands footer tests to cover all priced views and responsive behavior. |
| internal/ui/quota_api_eq.go | Implements the quota API‑equivalent sampling, trimming, estimation, confidence gating, and responsive rendering. |
| internal/ui/quota_api_eq_test.go | Adds estimator correctness tests, account isolation, fail-closed cases, and responsive UI coverage. |
| internal/ui/preferences.go | Clarifies that operational/account/quota-estimation data is never stored. |
| internal/ui/preferences_test.go | Uses deep equality for preferences round-trip assertions. |
| internal/ui/model.go | Brackets quota fetches with local accounting reads and wires observation/telemetry issue states into the model. |
| internal/ui/model_test.go | Adds tests for stable accounting bracket requirements and telemetry failure surfacing. |
| internal/ui/meters.go | Supports multi-line meter details rendering (needed for API‑EQ + attribution lines). |
| internal/codex/types.go | Adds snapshot account fingerprint and propagates LimitID into Meter for attribution/eligibility logic. |
| internal/codex/live_usage.go | Extends rollout decoding to capture per-call model and compute per-response standard API‑equivalent costs (fail closed). |
| internal/codex/live_usage_test.go | Adds tests for model pricing, mid-turn model recovery, and event-order pricing behavior. |
| internal/codex/client.go | Requests account identity (optional) and derives an anonymized fingerprint for account-isolated observation. |
| internal/codex/client_test.go | Verifies fingerprint anonymization and tolerates missing account identity support. |
| internal/codex/benchmark.go | Renames pricing provenance constants, adds long-context tiers, and applies long-context thresholds per raw response. |
| internal/codex/benchmark_test.go | Adds tests for long-context pricing and per-response threshold application / fail-closed cumulative-only cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Method
Codexometer prices newly completed local model calls from content-free rollout telemetry. It uses the requested model durably stored in each turn context and prices ordinary input, cached input, cache-write input, and output separately. Current rollout files do not persist transient server-side model reroutes, so the implementation and documentation no longer claim they can be reconstructed.
Each refresh reads cumulative local accounting immediately before and after the account quota request. If any priced-cost, priced-call, or unpriced-call counter changes, the observation is deferred rather than pairing asynchronous telemetry with the wrong quota snapshot.
For each primary
codexwindow, a sample requires at least five clean displayed percentage points without a reset, counter regression, unpriced call, or local coverage gap. The central capacity estimate isobserved API-equivalent cost × 100 / percentage movement; bounds usemovement ± 1to represent the quota API's integer granularity. Current spend-equivalent is the capacity range multiplied by the current used percentage.Additional/model-specific rate limits display
LIMIT ATTRIBUTION UNKNOWN: the rate-limit response does not expose enough information to assign aggregate local model costs safely to those buckets.Safeguards and privacy
account/readidentity is immediately reduced to an in-memory one-way fingerprint; neither the email nor fingerprint is persistedACCOUNT ATTRIBUTION UNKNOWNThe README states that this is a workload-dependent standard API-equivalent—not an account balance, invoice, subscription valuation, contractual allowance, or disclosure of OpenAI's quota formula.
Pricing
Sources: OpenAI API pricing, GPT-5.4, and GPT-5.5.
The demo advances by five points per refresh, so
codexometer --demofollowed byrimmediately demonstrates a learned estimate.Verification
go test ./...go test -race -cover ./...go vet ./...git diff --checkcodexometer --check-authagainst the prevailing local Codex session: 2 quota meters onlineRace coverage: root 67.9%,
internal/codex84.7%,internal/ui91.1%,internal/version81.0%.