rtk-ai / rtk-ai/rtk

fix(economics): use tracked monthly savings percentage

Open Beginner friendly
#3,972 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:performance bug good first issue priority:medium
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.