Unify z.AI and GPT subscription quotas for desktop telemetry #82

Open
nsaspy wants to merge 7 commits from feat/79-quota-telemetry into main
Owner

Implements #79's provider-reported quota backend. Qtile consumer: lost-rob0t/dotfiles#237.

Behavior

  • Normalize z.AI and GPT provider-reported percentages USED, window durations, reset times and plan metadata. No hard-coded plan capacities, token-to-credit guesses or fabricated zero/unlimited states.
  • z.AI fixed authenticated quota endpoint supports reported coding token/credit windows, including five-hour and weekly. Unknown shapes remain unknown; MCP time limits are not relabelled as coding quota.
  • GPT uses supported Codex App Server account/read and account/rateLimits/read, retaining rateLimitsByLimitId and using the existing ChatGPT login. Scope is Codex, NOT every ChatGPT chat/voice/model limit. No model thread/turn is started.
  • A bounded asyncio queue actor owns last-good observations. Bounded provider requests/RPCs, retry backoff, safe errors and no credentials in published state.
  • llm-log-quotas exposes cached GET /api/v1/quotas on loopback:8788 and an atomic 0600 XDG cache for desktop widgets. No provider requests on API GET; browser origins/unrecognized Host names rejected.
  • Home Manager service and runtime-only credentials/config paths are independently selectable from the forwarding runtime. Operational docs remain Org-mode.

Executed verification

Final exact head: 2feb4c6bf8.

  • GREEN Quota telemetry run 34733190676: Nix package/full Python tests, CLI entrypoint, Nix syntax and evaluated Home Manager proxy/expert/quota service contract.
  • GREEN Analytics API run 34733190651.
  • Decoded package output: 76 tests, OK with two existing expert-runtime skips. All 20 added quota tests pass, including normalization, plans, stale/reset semantics, actor/cache/API and fake-Codex subprocess handshake.
  • Test-first missing-module RED executed before implementation. CI fixture follow-ups use sys.executable inside Nix and correctly evaluate Home Manager conditional service definitions; checks were not removed.

Boundaries

No live subscription credentials, user desktop access, Home Manager activation, Forgejo synchronization or deployment occurred. Authentication failures are unavailable, never 0%. z.AI unit mapping is source-observed rather than a published stable schema guarantee. This PR does not certify or merge the separate Woo transport/rate stack; attempted repair #81 remains draft after the full transport timeout.

Implements #79's provider-reported quota backend. Qtile consumer: lost-rob0t/dotfiles#237. ## Behavior - Normalize z.AI and GPT provider-reported percentages USED, window durations, reset times and plan metadata. No hard-coded plan capacities, token-to-credit guesses or fabricated zero/unlimited states. - z.AI fixed authenticated quota endpoint supports reported coding token/credit windows, including five-hour and weekly. Unknown shapes remain unknown; MCP time limits are not relabelled as coding quota. - GPT uses supported Codex App Server account/read and account/rateLimits/read, retaining rateLimitsByLimitId and using the existing ChatGPT login. Scope is Codex, NOT every ChatGPT chat/voice/model limit. No model thread/turn is started. - A bounded asyncio queue actor owns last-good observations. Bounded provider requests/RPCs, retry backoff, safe errors and no credentials in published state. - llm-log-quotas exposes cached GET /api/v1/quotas on loopback:8788 and an atomic 0600 XDG cache for desktop widgets. No provider requests on API GET; browser origins/unrecognized Host names rejected. - Home Manager service and runtime-only credentials/config paths are independently selectable from the forwarding runtime. Operational docs remain Org-mode. ## Executed verification Final exact head: 2feb4c6bf8ed8801b7cb864b68c4a9c61565ffd8. - GREEN Quota telemetry run 34733190676: Nix package/full Python tests, CLI entrypoint, Nix syntax and evaluated Home Manager proxy/expert/quota service contract. - GREEN Analytics API run 34733190651. - Decoded package output: 76 tests, OK with two existing expert-runtime skips. All 20 added quota tests pass, including normalization, plans, stale/reset semantics, actor/cache/API and fake-Codex subprocess handshake. - Test-first missing-module RED executed before implementation. CI fixture follow-ups use sys.executable inside Nix and correctly evaluate Home Manager conditional service definitions; checks were not removed. ## Boundaries No live subscription credentials, user desktop access, Home Manager activation, Forgejo synchronization or deployment occurred. Authentication failures are unavailable, never 0%. z.AI unit mapping is source-observed rather than a published stable schema guarantee. This PR does not certify or merge the separate Woo transport/rate stack; attempted repair #81 remains draft after the full transport timeout.
Author
Owner

Final quota backend head: 2feb4c6bf8.

Verified GREEN at this exact head:

  • Quota telemetry run 34733190676: package/full Python contracts, CLI entrypoint, Nix syntax and evaluated Home Manager proxy/expert/quota service contract all passed.
  • Analytics API run 34733190651: passed.
  • The decoded package test output on this runtime reported 76 tests, OK with two existing expert-runtime skips; the 20 new quota normalization/actor/cache/API/Codex-handshake tests pass.

Two CI fixture issues were repaired without weakening production checks: use sys.executable rather than /usr/bin/env in the subprocess fixture, and model conditional Home Manager services as submodules with context-free comparison needles. Production provider telemetry behavior did not change in those follow-ups.

Dotfiles PR lost-rob0t/dotfiles#237 is pinned to this exact head. No live subscription credential verification, user-host activation, Forgejo synchronization or deployment occurred. GPT remains explicitly Codex quota scope under ChatGPT authentication, not all ChatGPT chat/voice/model usage. The separate gateway transport repair #81 is still blocked and unmerged.

Final quota backend head: 2feb4c6bf8ed8801b7cb864b68c4a9c61565ffd8. Verified GREEN at this exact head: - Quota telemetry run 34733190676: package/full Python contracts, CLI entrypoint, Nix syntax and evaluated Home Manager proxy/expert/quota service contract all passed. - Analytics API run 34733190651: passed. - The decoded package test output on this runtime reported 76 tests, OK with two existing expert-runtime skips; the 20 new quota normalization/actor/cache/API/Codex-handshake tests pass. Two CI fixture issues were repaired without weakening production checks: use sys.executable rather than /usr/bin/env in the subprocess fixture, and model conditional Home Manager services as submodules with context-free comparison needles. Production provider telemetry behavior did not change in those follow-ups. Dotfiles PR lost-rob0t/dotfiles#237 is pinned to this exact head. No live subscription credential verification, user-host activation, Forgejo synchronization or deployment occurred. GPT remains explicitly Codex quota scope under ChatGPT authentication, not all ChatGPT chat/voice/model usage. The separate gateway transport repair #81 is still blocked and unmerged.
Some checks failed
Quota telemetry / contracts (push) Failing after 3s
Quota telemetry / contracts (pull_request) Failing after 3s
Analytics API / test (pull_request) Failing after 4s
Analytics API / package (pull_request) Has been skipped
This pull request has changes conflicting with the target branch.
  • .github/workflows/quota-telemetry.yml
  • llm_log/quotas.py
  • roam/index.org
  • roam/solutions/provider-quota-telemetry.org
  • tests/test_quotas.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/79-quota-telemetry:feat/79-quota-telemetry
git switch feat/79-quota-telemetry

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feat/79-quota-telemetry
git switch feat/79-quota-telemetry
git rebase main
git switch main
git merge --ff-only feat/79-quota-telemetry
git switch feat/79-quota-telemetry
git rebase main
git switch main
git merge --no-ff feat/79-quota-telemetry
git switch main
git merge --squash feat/79-quota-telemetry
git switch main
git merge --ff-only feat/79-quota-telemetry
git switch main
git merge feat/79-quota-telemetry
git push origin main
Sign in to join this conversation.
No description provided.