calibrate: opt-in plan-window utilization sampler - #983
Closed
iamtoruk wants to merge 1 commit into
Closed
Conversation
Records Anthropic's live plan-window utilization (five_hour / seven_day / model-scoped weekly, the same oauth/usage endpoint the menubar polls) into a local JSONL so the deltas can be regressed against the local token record to recover per-model plan-burn weights. - codeburn calibrate --enable/--disable/--sample, status always printed - serve rides a 60s tick; real spacing enforced by a 5-min mtime throttle - token from ~/.claude/.credentials.json, else the macOS keychain item - off by default; samples never leave the machine
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.
First piece of plan-burn calibration (the 'why did one session eat 27% of my week' problem).
What
codeburn calibrate --enableturns on a local sampler: the resident serve process records Anthropic's live plan-window utilization (five_hour, seven_day, and model-scoped weekly buckets from the same oauth/usage endpoint the menubar already polls) into~/.cache/codeburn/usage-samples.jsonl.Each sample pairs a timestamp with the plan percentages. Combined with the token record CodeBurn already has for any interval, every pair of samples becomes an equation (delta plan-% vs tokens by model and type), so per-model plan-burn weights can be fitted after a few days of data. That unlocks per-session plan-% attribution, cap forecasts, and burn-rate change detection.
Details
--enable/--disablepersist to config;--sampletakes one now; barecalibrateprints status, sample count and span, and the file path~/.claude/.credentials.jsonwhere present, else the macOS keychain item Claude Code writes (one-time Always Allow)Tests
Response parsing against the captured endpoint shape (windows + scoped limits + rejects), mtime throttle behavior, and samples summary. Suite and tsc green.