feat(claude): surface scoped weekly limits[] (Fable promo) as extra rate windows - #1838
feat(claude): surface scoped weekly limits[] (Fable promo) as extra rate windows#1838valkyriweb wants to merge 1 commit into
Conversation
Anthropic's usage APIs (claude.ai web + OAuth) now return a limits[]
array alongside the legacy window fields. Entries with
kind == "weekly_scoped" carry per-model promo quotas (e.g. the
"Fable" scoped weekly limit) that were previously invisible.
Map those entries into extraRateWindows on both fetch paths:
- title from scope.model.display_name ("Fable weekly")
- percent -> usedPercent, resets_at -> resetsAt, 7-day window
- included regardless of is_active when percent is non-null
Legacy top-level fields stay authoritative for the session/weekly/
model windows; session and weekly_all limits[] kinds are ignored to
avoid duplicating those lanes. Payloads without limits[] are
unchanged.
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 5:53 AM ET / 09:53 UTC. Summary Reproducibility: not applicable. this is a feature PR adding visibility for a newly reported Claude API field, not a current-main bug report with reproduction steps. 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. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one Claude scoped-weekly implementation after maintainers compare the overlapping open PRs and see redacted real output proving the new quota appears correctly. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature PR adding visibility for a newly reported Claude API field, not a current-main bug report with reproduction steps. Is this the best way to solve the issue? Unclear until the overlapping open PR is compared; this branch is narrow and follows existing extra-rate-window seams, but maintainers should choose one implementation path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 450ca4d91565. Label changesLabel changes:
Label 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
|
|
Closing — keeping this on my fork for now. |
What
Anthropic's usage APIs now return a
limits[]array alongside the legacy window fields — on both the claude.ai web API (GET /api/organizations/{orgId}/usage) and the OAuth API (GET /api/oauth/usage). Entries withkind == "weekly_scoped"carry per-model promo quotas, currently the "Fable 5" promo (≤50%-weekly-usage users get scoped Fable access through Jul 7 2026):{"kind":"weekly_scoped","group":"weekly","percent":70,"severity":"normal", "resets_at":"2026-07-08T06:00:00+00:00", "scope":{"model":{"id":null,"display_name":"Fable"},"surface":null},"is_active":true}CodexBar ignored
limits[]entirely, so this quota was invisible. This PR surfaces scoped weekly limits as extra rate windows (same mechanism as "Daily Routines"), so they render in the menu dropdown and CLI JSON with no UI changes.Mapping contract
ClaudeScopedWeeklyLimitWindows, used by both the web parser and the OAuth path.kind == "weekly_scoped"is mapped.session/weekly_allkinds are ignored — the legacy top-level fields stay authoritative for those lanes, so nothing gets duplicated.scope.model.display_name→ "Fable weekly" (fallback "Scoped weekly"); idclaude-scoped-<slug>.percent→usedPercent,resets_at→resetsAt,windowMinutes= 10080.is_activewhenpercentis non-null (an untouched scoped quota still shows a bar); entries with nullpercentare skipped.limits[]are byte-for-byte unchanged in behavior.Tests
Tests/CodexBarTests/ClaudeScopedWeeklyLimitTests.swift— 7 tests across both paths:limits[]unchanged (routines window untouched)swift buildandmake check(swiftformat + swiftlint, 0 violations) pass.swift test: all 7 new tests plus the Claude suites pass; the only local failures are pre-existing timing/environment flakes (fnm/login-runner/memory-pressure/codex-home hydration) that fail identically onmain(verified on 450ca4d).