Skip to content

feat(claude): surface scoped weekly limits[] (Fable promo) as extra rate windows - #1838

Closed
valkyriweb wants to merge 1 commit into
steipete:mainfrom
valkyriweb:feat/claude-scoped-weekly-limits
Closed

feat(claude): surface scoped weekly limits[] (Fable promo) as extra rate windows#1838
valkyriweb wants to merge 1 commit into
steipete:mainfrom
valkyriweb:feat/claude-scoped-weekly-limits

Conversation

@valkyriweb

Copy link
Copy Markdown

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 with kind == "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

  • Shared mapper: ClaudeScopedWeeklyLimitWindows, used by both the web parser and the OAuth path.
  • Only kind == "weekly_scoped" is mapped. session / weekly_all kinds are ignored — the legacy top-level fields stay authoritative for those lanes, so nothing gets duplicated.
  • Title from scope.model.display_name → "Fable weekly" (fallback "Scoped weekly"); id claude-scoped-<slug>.
  • percentusedPercent, resets_atresetsAt, windowMinutes = 10080.
  • Included regardless of is_active when percent is non-null (an untouched scoped quota still shows a bar); entries with null percent are skipped.
  • Payloads without limits[] are byte-for-byte unchanged in behavior.

Tests

Tests/CodexBarTests/ClaudeScopedWeeklyLimitTests.swift — 7 tests across both paths:

  • web: active Fable entry mapped (title/percent/window/reset), inactive entry still included, null-percent skipped, legacy payload without limits[] unchanged (routines window untouched)
  • OAuth: active entry mapped + legacy session/weekly stay authoritative, inactive entry included, legacy payload unchanged

swift build and make 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 on main (verified on 450ca4d).

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.
@clawsweeper

clawsweeper Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 5:53 AM ET / 09:53 UTC.

Summary
The PR adds Claude weekly_scoped entries from web and OAuth limits[] payloads as extra weekly rate windows, with focused parser tests.

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.

  • Diff scope: 5 files, +309/-2. The change is narrowly scoped to Claude parser mapping and focused tests.
  • Claude data paths: 2 paths changed. Both OAuth and web usage payload parsing are changed, so proof should cover at least one real payload path and tests cover both.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body reports local build/check/test results but does not include after-fix real behavior proof; add redacted CLI/menu output, logs, screenshot, or recording and update the PR body to trigger re-review.

Risk before merge

  • [P1] Real behavior proof is missing; the PR has parser tests but does not show a redacted live Claude payload, CLI JSON, or menu output after the change.
  • [P1] Another open PR, feat(claude): weekly Fable usage tracking across menu, CLI, and widget #1837, targets the same Fable scoped-weekly quota with a broader first-class lane, so maintainers need to choose the preferred surface before merging either branch.

Maintainer options:

  1. Decide the mitigation before merge
    Land one Claude scoped-weekly implementation after maintainers compare the overlapping open PRs and see redacted real output proving the new quota appears correctly.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Maintainers should compare the overlapping scoped-weekly Claude PRs and request real behavior proof before choosing a landing branch.

Security
Cleared: The diff only parses additional fields from existing Claude usage API responses and adds tests; no concrete security or supply-chain concern was found.

Review details

Best 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 changes

Label changes:

  • add P2: The PR improves Claude usage visibility for a bounded provider parser surface.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports local build/check/test results but does not include after-fix real behavior proof; add redacted CLI/menu output, logs, screenshot, or recording and update the PR body to trigger re-review.

Label justifications:

  • P2: The PR improves Claude usage visibility for a bounded provider parser surface.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports local build/check/test results but does not include after-fix real behavior proof; add redacted CLI/menu output, logs, screenshot, or recording and update the PR body to trigger re-review.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Recent Claude usage, OAuth isolation, quota-gap, and Fable pricing work touches the same provider area and related maintainer routing surface. (role: recent area contributor / merger; confidence: high; commits: c57de22c9ffe, 92bbb7a67073, 81091f977185; files: Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeProviderDescriptor.swift)
  • kmatsunami: Blame and history attribute the current Claude web/OAuth usage fetcher baseline and extra rate-window parser path to this author. (role: introduced behavior; confidence: high; commits: 5bfd1d1474bb; files: Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeWeb/ClaudeWebAPIFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeWeb/ClaudeWebExtraRateWindowParser.swift)
  • Shengqiang Zhang: Recently changed Claude web usage placeholder handling adjacent to the same parser/projection path. (role: recent adjacent contributor; confidence: medium; commits: d2690d4176b3; files: Sources/CodexBarCore/Providers/Claude/ClaudeUsageFetcher.swift, Sources/CodexBarCore/Providers/Claude/ClaudeWeb/ClaudeWebAPIFetcher.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. labels Jul 2, 2026
@valkyriweb

Copy link
Copy Markdown
Author

Closing — keeping this on my fork for now.

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant