Skip to content

fix(server): update all Claude unified usage windows - #14441

Open
nightyard wants to merge 3 commits into
pingdotgg:mainfrom
nightyard:fix/claude-unified-usage
Open

nightyard wants to merge 3 commits into
pingdotgg:mainfrom
nightyard:fix/claude-unified-usage

Conversation

@nightyard

@nightyard nightyard commented Sep 30, 2026 •

Copy link
Copy Markdown

Claude can stream session and weekly usage together in rate_limit_info.unifiedWindows without naming a top-level window. T3 Code dropped those events, leaving usage stale until the next probe.

The mapper now reads every supported nested window and merges the legacy top-level window last, preserving its precedence. It reuses the overage bucket name established by the probe and ignores malformed or unsupported entries. The fix follows the module relocation on current main; no wire or client changes are needed.

Verification on head 5e7d4ba029f1738b8e38310d44ce2f946a64fa86:

  • Reduced the original three added tests to two focused cases in the existing test file: 10 tests before → nine after, including seven unchanged main cases.
  • Against main, both new regressions fail and seven cases pass. With the fix, all nine pass. The cases cover nested-only updates, IDs, percentages, reset times, named/unnamed overage, malformed entries, and top-level precedence while retaining another nested window.
  • Scoped lint, formatting, and diff checks pass. Server typecheck passes (suggestions only). Validation runs serially with nice -n 10, Vitest --maxWorkers=2.
  • Independent full-diff Opus and Sol reviews found no blockers.

These are synthetic mapper fixtures following the serializer shape identified by the contributor and independently confirmed in the installed Claude CLI 2.1.303, plus static inspection of the adapter-to-snapshot update path. No live Claude usage event, browser, or device was exercised. macOS, Windows, iOS, Android, and Electron desktop were not verified live; screenshots do not establish this server-side mapping behavior.

Thanks @nightyard for tracing the unified-window payload and precedence in #14441. Original commits are preserved, with main merged in. The production approach was retained after a fresh implementation assessment; redundant test structure and the stale module header were removed.

Implementation: GPT-6.1 Sol; tests: GPT-6 Astra; independent reviews: Claude Opus 5.5 and GPT-6 Sol. Harnesses: Codex and Claude Code through T3 Code.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 30, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 30, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 5e7d4ba

Macroscope's review found this PR approvable — This is a localized server-side fix that makes the existing Claude usage mapper consume all supported unified windows while preserving legacy precedence and sparse ID-based merging. The accompanying changes are tests only, with no schema, configuration, deployment, security, or billing impact.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8d9b2766-03ba-4a29-bec6-3627b3d3e304

📥 Commits

Reviewing files that changed from the base of the PR and between c2fa9fc and dc1d8f3.

📒 Files selected for processing (2)
  • apps/server/src/provider/Layers/claudeUsageLimits.test.ts
  • apps/server/src/provider/Layers/claudeUsageLimits.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The Claude rate-limit event mapper now processes unified windows alongside legacy top-level fields. It validates utilization values, maps recognized windows, and returns all mapped updates. Tests cover conversion, precedence, and invalid or unknown entries.

Changes: Claude usage limit event mapping

Layer / File(s) Summary
Map and validate usage windows
apps/server/src/provider/Layers/claudeUsageLimits.ts, apps/server/src/provider/Layers/claudeUsageLimits.test.ts
The mapper combines recognized unified windows with legacy top-level values. It skips malformed or invalid utilization values and returns mapped updates. Tests cover percentage conversion, reset timestamps, top-level precedence, and rejected entries.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to dc1d8

The change updates supported Claude usage windows together while preserving legacy precedence and bounded percentages. No actionable merge-blocking risk remains after normal checks.

Security architecture risk: 🔵 Low · up to dc1d8

The change preserves the existing instance-specific update path and validates recognized usage windows. No new privileged action or security vulnerability was established. Remaining uncertainty concerns upstream data assumptions and lifecycle behavior, rather than a demonstrated boundary bypass.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated impact is usage telemetry within the originating provider instance. The exported mapper remains behind the existing SDK message handler; the traced update path changes snapshot usageLimits, not credentials, permissions, tool authority, or enforcement decisions.

Trust Boundaries and Controls

  • observed — ProviderService obtains source identity from the adapter registry, rejects provider or instance mismatches, and stamps providerInstanceId before publishing events. Ingestion discards events without an identity or a matching registered instance. This resolves the concern raised by the adapter’s locally unstamped event.

Resilience and Maintainability Implications

  • observed — The mapper skips unsupported entries and nonnumeric, negative, or nonfinite utilization. Downstream ingestion isolates failures per event. Multiplication of an extremely large finite fraction can produce Infinity, which the existing clamp converts to zero; this preserves schema bounds but not saturated usage semantics.
Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the server fix for updating all Claude unified usage windows.
Description check Passed The description explains the problem, implementation, scope, verification results, test limitations, and review context. It does not use the template headings or provide an explicit maintainer approva…
Full details: Description check

Explanation

The description explains the problem, implementation, scope, verification results, test limitations, and review context. It does not use the template headings or provide an explicit maintainer approval comment, but the required information is mostly present.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 1, 2026 15:56

Dismissing prior approval to re-evaluate dc1d8f3

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Oct 1, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Taking over this one as maintainer for batch claude-04. I will preserve your commits, move the focused mapper fix onto current main, trim the regression coverage, and run independent reviews before pushing. Thanks for tracing the unified-window stream payload and top-level precedence.

@macroscopeapp
macroscopeapp Bot dismissed their stale review October 19, 2026 20:41

Dismissing prior approval to re-evaluate 5e7d4ba

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants