feat(usage): token collection pipeline + rate-limit bucket tracking#3
Merged
feat(usage): token collection pipeline + rate-limit bucket tracking#3
Conversation
Fixes the "Format check" step on this PR's CI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usage_taileractor starts alongside each container, pollsruns/<id>/mount/**/*.jsonlevery 2s, parses Claude's JSONL output, and atomically writes token counts torun_usage_events+runs.tokens_*. Live{"type":"usage"}frames flow over the run WebSocket soRunUsageupdates in real-time during a run.rate_limit_buckets.GET /api/usagenow returns real data (utilization bars, countdown timers) instead of themissing_credentialsstub. The usage WebSocket publishes{"type":"snapshot"}frames on every bucket update.{"type":"threshold_crossed"}on the usage pubsub (picked up byUsageNotifierfor browser notifications). Pacing verdicts (chill/on_track/hot) are computed fromwindow_started_at/reset_atand included in every snapshot.Test plan
RunUsagein the drawer populate with live token counts/usagepage shows bucket utilization bars and countdown timers after the first JSONL line withrateLimitsis parsedGET /api/usage/dailyreturns non-zero token totals after a completed runmake test-serverpasses (48 tests)🤖 Generated with Claude Code