fix: bucket Codex usage by token_count deltas#11
Conversation
aqua5230
left a comment
There was a problem hiding this comment.
Thanks for the careful change. The semantic shift from cumulative to delta makes sense for accurate bucketing, but it
leaves v0.11.6's fast path inconsistent: analyzer/reporter.py:115-212 (_load_recent_codex_entries and
_parse_codex_file) still reads the final cumulative snapshot and uses session-start time as the entry timestamp, so
today/week/month reports will diverge from what the popover shows once your new loader lands.
Could you:
- Either reuse
codex_loader's new delta logic in the reporter fast path, or update_load_recent_codex_entriesto
bucket bytoken_countevent timestamp the same way? - Add a reporter-layer test proving today/week/month reports pick up the deltas (not just the loader-level test)?
Happy to merge once these are in.
446f377 to
3d24caa
Compare
|
Updated, thanks. I rebased onto current main and removed the separate reporter Codex cumulative fast parser. The reporter recent path now reuses codex_loader.load_entries(hours_back=...), so today/week/month reports use the same token_count delta logic as the popover. I also added a reporter-layer today test that exercises a cross-day cumulative Codex session and verifies only the current-day delta is counted.\n\nValidation run locally:\n- .venv/bin/python -m pytest tests/test_codex_loader.py tests/test_analyzer_pipeline.py\n- .venv/bin/python -m ruff check analyzer/reporter.py tests/test_analyzer_pipeline.py\n- .venv/bin/python -m mypy . |
- fix(badge): clear update hint immediately after upgrade past cached latest - fix(reporter): bucket Codex usage by token_count deltas (#11, @ericweichun) - fix(reports): tie All Time reports to project range selector (#15, @ericweichun) - fix(refresh): queue manual refresh while busy (#12, @ericweichun) - docs(setup): make setup guidance agent-neutral (#16, @ericweichun) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Test plan
Notes for reviewer
This keeps the rate-limit parser unchanged. It only changes the historical usage entries emitted from Codex session logs so downstream aggregators can bucket usage by each token_count event timestamp.