Skip to content

Update scheduler from fresh usage status#46

Merged
lawrencecchen merged 1 commit into
mainfrom
fix/status-refreshes-fable-scheduler
Jul 3, 2026
Merged

Update scheduler from fresh usage status#46
lawrencecchen merged 1 commit into
mainfrom
fix/status-refreshes-fable-scheduler

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • marks usage-status rows as fresh only when they came from a live usage fetch, not last-good fallback
  • updates the routing scheduler from fresh /usage-status windows so sr visibility and routing state converge
  • adds coverage proving a fresh Fable status cooks only the claude-fable-5 model pool while leaving base Claude routing usable

Tests

  • go test ./...

Live finding

After PRs 44 and 45, sr correctly showed Fable wk = 0%, but a cold service could still learn by failover because the status sweep did not publish fresh Fable windows into SchedulerRef.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Updates the routing scheduler from fresh /usage-status data so status and routing stay in sync, preventing failover “learning” when Fable is exhausted. Also adds a test proving only the claude-fable-5 model pool is cooked while base Claude stays routable.

  • Bug Fixes
    • Mark usage rows as fresh only when fetched live; last-good fallbacks are not fresh.
    • On /usage-status, refresh SchedulerRef using only fresh OAuth statuses; seed from current scores and retain session counts.
    • Propagate freshness through AccountUsageStatus and FetchUsageWindowsCached.
    • Add test that a fresh Fable window exhausts only the claude-fable-5 pool, leaving base Claude usable.

Written for commit e04fdb6. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@lawrencecchen, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d060af0d-830f-4bc8-89ca-fcee70262203

📥 Commits

Reviewing files that changed from the base of the PR and between eb58a36 and e04fdb6.

📒 Files selected for processing (2)
  • internal/proxy/claude_ratelimit_routing_test.go
  • internal/proxy/proxy.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/status-refreshes-fable-scheduler

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@lawrencecchen lawrencecchen merged commit 4716040 into main Jul 3, 2026
5 checks passed
@lawrencecchen lawrencecchen deleted the fix/status-refreshes-fable-scheduler branch July 3, 2026 04:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e04fdb6d83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/proxy/proxy.go
Comment on lines +1002 to +1004
if !status.UsageFresh || status.AuthMode != accounts.AuthModeOAuth || len(status.Windows) == 0 {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not carry healthy scores for auth-failed status rows

In an AccountRef-backed /_subrouter/usage-status sweep, a row whose OAuth refresh failed (for example invalid_grant) has AuthMode=oauth, no windows, and an error, so this condition skips it. If any other account in the same response is fresh, the function still publishes a new scheduler seeded from the old scores and advances updatedAt; the account that the sweep just proved has bad credentials can therefore keep a prior healthy score and be selected until another refresh or failed request marks it. The usage-status publisher should zero auth-like failures the same way scoreAccounts does before calling Set.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant