fix(economics): use tracked monthly savings percentage
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 81.1k
- Forks
- 5.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 35
Description
Problem
PeriodEconomics::set_rtk_from_month recomputes rtk_savings_pct as:
saved_tokens / (saved_tokens + input_tokens + output_tokens) * 100
This disagrees with DayStats, WeekStats, and MonthStats, which define savings percentage as saved_tokens / input_tokens * 100. Because saved_tokens = input_tokens - output_tokens, the current monthly-economics denominator is normally 2 * input_tokens, under-reporting the percentage by about half and skewing rtk_avg_savings_pct.
Proposed fix
Use MonthStats::savings_pct directly in set_rtk_from_month, matching the day and week paths. Add a focused monthly-economics regression test.
Scope
This is intentionally separate from #3958, which only propagates signed saved-token deltas. #3958 provides the negative-savings coverage once its signed model lands.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at PeriodEconomics::set_rtk_from_month and compare its rtk_savings_pct calculation with MonthStats::savings_pct and the day and week paths. Use the existing monthly economics test area, or add a focused regression test, and verify that monthly savings and rtk_avg_savings_pct use the tracked percentage without changing the signed-delta work in #3958.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100