Skip to content

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

Open
nightyard wants to merge 1 commit into
pingdotgg:mainfrom
nightyard:fix/claude-unified-usage
Open

nightyard wants to merge 1 commit into
pingdotgg:mainfrom
nightyard:fix/claude-unified-usage

Conversation

@nightyard

Copy link
Copy Markdown

fix(server): update all Claude unified usage windows

What Changed

Read every supported window from Claude Code's rate_limit_info.unifiedWindows, keeping the existing top-level update authoritative for its window. Reuse the model-scoped bucket established by the usage probe and ignore malformed or unsupported entries.

Why

Claude Code can emit session and weekly usage together without a top-level window. The existing mapper drops that event, leaving usage stale until the next probe. The CLI's own stream-json schema and print-mode serializer confirm the nested window names, utilization fractions, and camel-case resetsAt fields.

Validation

Synthetic fixtures follow the statically inspected Claude Code 2.1.281 serializer shape; they contain no captured account data. On unchanged main, the focused suite reports two regression failures and eight passing tests. With the fix, all ten tests pass using vp test run apps/server/src/provider/Layers/claudeUsageLimits.test.ts --maxWorkers=2. Scoped lint, formatting, and a TypeScript check of the mapper/test import closure pass on Node 24.13.1. No live provider calls or UI verification were performed.

Checklist

  • This PR is small and focused
  • I explained what changed and why

AI-assisted: implemented with GPT-6.1 Sol (Codex) and independently reviewed by Claude; human-approved before submission.

@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 dc1d8f3

Macroscope's review found this PR approvable — This is a focused server-side bug fix that expands an existing Claude usage-event mapper to report all supported windows while preserving legacy behavior. The production impact is limited to more complete, fresher usage-limit telemetry, with targeted tests and no schema, deployment, authentication, billing, or default-setting changes.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

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

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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

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 Review

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 | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the server-side fix to update all Claude unified usage windows.
Description check ✅ Passed The description includes clear What Changed and Why sections, validation details, and the applicable checklist items. No UI section is needed because the changes are server-only.
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.
✨ 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

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