Provider-reported z.AI / GPT quotas for the Qtile widget pair #81

Closed
nsaspy wants to merge 0 commits from feat/79-provider-quota-telemetry into main
Owner

Implements the backend portion of #79; consumer tracked in lost-rob0t/dotfiles#233. User priority is the adjacent z.AI and GPT widgets before the new grapher.

Implemented

  • GET /api/v1/quotas in the Python capture/analytics runtime, with a versioned sanitized snapshot.
  • Single asyncio snapshot owner, bounded independent provider refreshes, provider Retry-After, explicit missing/stale/expired/disabled states.
  • z.AI source-verified monitor endpoint; reported 5h/weekly period fields and percentages, no quota/token conversion or plan-cap guesses.
  • GPT managed Codex App Server account/read and account/rateLimits/read, dynamic plan metadata and per-meter windows; no inference or new login. Codex meters are not claimed to be all ChatGPT web/voice quotas.
  • Local-only, anti-rebinding/Origin-denying, no-store HTTP reads. Reads never invoke providers. Optional atomic 0600 cache; no raw credentials/email/error bodies exported.
  • Integrated through the existing analytics installer and documented in OpenAPI.
  • Exact-head Nix/Python package CI, with existing transport gates untouched.

Executed local verification

14 new Python/aiohttp tests pass, including a real loopback HTTP server and actual fake Codex subprocess handshake. Tests were written and run first: missing-module import RED, then 14-test GREEN. Python 3.13.5 / aiohttp 3.13.3. This is not a live-provider or Nix result.

Enablement / remaining verification

Set LLM_LOG_QUOTAS_ENABLED=1 on the Python capture service, provide a private local ZAI key file/env and an already-authenticated codex executable in the service environment. Those credentials and the user's machine are not available here. No deployment or live quota read is claimed. Full exact-head CI/package checks must pass before merging.

The independent Common Lisp Woo transport blocker on #74, and stacked rate/profile PRs #76/#77, remain unverified and are NOT represented as repaired by this telemetry PR.

Implements the backend portion of #79; consumer tracked in lost-rob0t/dotfiles#233. User priority is the adjacent z.AI and GPT widgets before the new grapher. ## Implemented - `GET /api/v1/quotas` in the Python capture/analytics runtime, with a versioned sanitized snapshot. - Single asyncio snapshot owner, bounded independent provider refreshes, provider Retry-After, explicit missing/stale/expired/disabled states. - z.AI source-verified monitor endpoint; reported 5h/weekly period fields and percentages, no quota/token conversion or plan-cap guesses. - GPT managed Codex App Server account/read and account/rateLimits/read, dynamic plan metadata and per-meter windows; no inference or new login. Codex meters are not claimed to be all ChatGPT web/voice quotas. - Local-only, anti-rebinding/Origin-denying, no-store HTTP reads. Reads never invoke providers. Optional atomic 0600 cache; no raw credentials/email/error bodies exported. - Integrated through the existing analytics installer and documented in OpenAPI. - Exact-head Nix/Python package CI, with existing transport gates untouched. ## Executed local verification 14 new Python/aiohttp tests pass, including a real loopback HTTP server and actual fake Codex subprocess handshake. Tests were written and run first: missing-module import RED, then 14-test GREEN. Python 3.13.5 / aiohttp 3.13.3. This is not a live-provider or Nix result. ## Enablement / remaining verification Set LLM_LOG_QUOTAS_ENABLED=1 on the Python capture service, provide a private local ZAI key file/env and an already-authenticated codex executable in the service environment. Those credentials and the user's machine are not available here. No deployment or live quota read is claimed. Full exact-head CI/package checks must pass before merging. The independent Common Lisp Woo transport blocker on #74, and stacked rate/profile PRs #76/#77, remain unverified and are NOT represented as repaired by this telemetry PR.
test(analytics): cover the added quota endpoint without weakening existing contracts
Some checks failed
Quota telemetry exact-head contract / quota-contracts (push) Failing after 3s
Analytics API / test (pull_request) Failing after 4s
Analytics API / package (pull_request) Has been skipped
Quota telemetry exact-head contract / quota-contracts (pull_request) Failing after 4s
890efb49bd
feat(analytics): add per-field graph coverage and bounded nonblocking corpus readers
Some checks failed
Quota telemetry exact-head contract / quota-contracts (push) Failing after 5s
Analytics API / test (pull_request) Failing after 4s
Quota telemetry exact-head contract / quota-contracts (pull_request) Failing after 5s
Analytics API / package (pull_request) Has been skipped
171cf7a21a
nsaspy closed this pull request 2026-09-13 03:01:28 +00:00
Author
Owner

Merged as 9f9971053d with the expected-head guard on 171cf7a21a. Both workflows on that implementation head passed: Analytics API 34732810083 and Quota telemetry exact-head contract 34732810084, including the full Python suite under Nix and the delivered Python package build/install checks.

The final implementation also includes opt-in timeline coverage=fields (per-input/output report counts, backwards-compatible basic responses), completed-request accounting metadata, and a maximum of two off-event-loop corpus readers. Cancelled HTTP waiters do not prematurely release a live reader permit; excess scans receive 503 + Retry-After. Quota reads remain snapshot-only and independent.

Consumer dotfiles#235 is merged and pins this tested implementation. Local cross-repository HTTP/Cairo testing used synthetic quota inputs, not live account data. No live service deployment, user credential access or Qtile-session activation is claimed. The separate Woo transport blocker on #74 and stacked #76/#77 remain unmerged and are not repaired by this telemetry work.

Merged as 9f9971053dc3796c70955105943de42716775513 with the expected-head guard on 171cf7a21a8a0f669ff07f3358fc82852c3406ef. Both workflows on that implementation head passed: Analytics API 34732810083 and Quota telemetry exact-head contract 34732810084, including the full Python suite under Nix and the delivered Python package build/install checks. The final implementation also includes opt-in timeline coverage=fields (per-input/output report counts, backwards-compatible basic responses), completed-request accounting metadata, and a maximum of two off-event-loop corpus readers. Cancelled HTTP waiters do not prematurely release a live reader permit; excess scans receive 503 + Retry-After. Quota reads remain snapshot-only and independent. Consumer dotfiles#235 is merged and pins this tested implementation. Local cross-repository HTTP/Cairo testing used synthetic quota inputs, not live account data. No live service deployment, user credential access or Qtile-session activation is claimed. The separate Woo transport blocker on #74 and stacked #76/#77 remain unmerged and are not repaired by this telemetry work.
Some checks failed
Quota telemetry exact-head contract / quota-contracts (push) Failing after 5s
Analytics API / test (pull_request) Failing after 4s
Quota telemetry exact-head contract / quota-contracts (pull_request) Failing after 5s
Analytics API / package (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No description provided.