Copilot: drop zero-entitlement quotas instead of showing "0% used" (#1258)#1270
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 1, 2026, 6:03 PM ET / 22:03 UTC. Summary Reproducibility: yes. there is a high-confidence source reproduction path: decode the linked Copilot Business token-billing payload on current main and pass its snapshots through makeRateWindow, which yields 0% windows instead of an unavailable state. I did not run live account probes because the repo policy says not to do credentialed provider validation unless explicitly requested. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow parser/fetcher fix, then track any future actual-usage endpoint for Copilot Business token billing as a separate enhancement if GitHub exposes one. Do we have a high-confidence way to reproduce the issue? Yes, there is a high-confidence source reproduction path: decode the linked Copilot Business token-billing payload on current main and pass its snapshots through makeRateWindow, which yields 0% windows instead of an unavailable state. I did not run live account probes because the repo policy says not to do credentialed provider validation unless explicitly requested. Is this the best way to solve the issue? Yes. The PR is the narrowest maintainable fix for the current endpoint: drop explicit zero-entitlement snapshots, preserve real positive-entitlement and percent-only quotas, and return a plan-only unavailable state for token-based billing. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 4756ba06bf42. Label changesLabel justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
GitHub Copilot Business token-based billing reports every quota as entitlement 0 / remaining 0 / percent_remaining 100. That rendered as a misleading "0% used" (100 - percent_remaining) because the placeholder guard only matched the all-zero shape with an empty quota_id. A zero-entitlement / zero-remaining snapshot carries no usable quota signal, so flag it as a placeholder and let the existing placeholder handling drop it. Quotas with a positive entitlement (including the "100% used" remaining-0 case) are unchanged. Adds parser and fetcher regression tests for the reported payload.
56d8f85 to
90a3fdf
Compare
Fixes #1258.
Problem. GitHub Copilot Business token-based billing returns every quota as
entitlement: 0, remaining: 0, percent_remaining: 100. CodexBar computes used percent as100 - percent_remaining, so these accounts showed a misleading "0% used" instead of recognizing the endpoint exposes no usable quota. The placeholder guard only caught the all-zero shape with an emptyquota_id, so thepercent_remaining: 100variant slipped through as a real window.Fix. A zero-entitlement / zero-remaining snapshot carries no usage signal, so treat it as a placeholder (
entitlement == 0 && remaining == 0). These now drop out the same way other empty/placeholder Copilot responses already do, so the account no longer shows a fake "0% used". Quotas with a positive entitlement are unchanged, including the genuine "100% used" case (guarded by a test).Tests. Added parser + fetcher regression tests for the reported payload. The three new assertions fail on
main(the fetcher test showsRateWindow(usedPercent: 0.0)) and pass after the change.Real-behavior proof. Running the production decode + rate-window path (
CopilotUsageResponsedecode →CopilotUsageFetcher.makeRateWindow) on the exact token-billing payload reported in #1258:Before (
main):After (this PR):
I don't have a live Copilot Business account, so this drives the real parsing/window code with the issue's verbatim payload rather than a live credentialed probe.
Verification.
swift test --filter CopilotUsageModelsTestsandCopilotUsageFetcherTestspass;make checkclean (parser hash current); fullswift test(3219 tests) passes.Used the Claude CLI while working on this.