Skip to content

calibrate: opt-in plan-window utilization sampler - #983

Closed
iamtoruk wants to merge 1 commit into
mainfrom
feat/plan-burn-sampler
Closed

calibrate: opt-in plan-window utilization sampler#983
iamtoruk wants to merge 1 commit into
mainfrom
feat/plan-burn-sampler

Conversation

@iamtoruk

Copy link
Copy Markdown
Member

First piece of plan-burn calibration (the 'why did one session eat 27% of my week' problem).

What

codeburn calibrate --enable turns 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

  • Off by default. --enable/--disable persist to config; --sample takes one now; bare calibrate prints status, sample count and span, and the file path
  • Serve rides a 60s unref'd tick; actual spacing is enforced by a 5-minute mtime throttle on the samples file, so extra ticks are free
  • OAuth token from ~/.claude/.credentials.json where present, else the macOS keychain item Claude Code writes (one-time Always Allow)
  • Every failure is a quiet typed outcome; sampling can never break the command or the serve loop
  • Local only: samples never leave the machine

Tests

Response parsing against the captured endpoint shape (windows + scoped limits + rejects), mtime throttle behavior, and samples summary. Suite and tsc green.

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
@iamtoruk iamtoruk closed this Aug 12, 2026
@iamtoruk
iamtoruk deleted the feat/plan-burn-sampler branch August 12, 2026 19:50
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