Skip to content

fix(economics): use tracked monthly savings percentage #3972

Open

Description

@Raymondtaoo

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.

Activity

  1. rtk-wshm-sync-bot commented on Sep 10, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 90%

    Summary

    PeriodEconomics::set_rtk_from_month recomputes savings percentage with a different (inconsistent) formula than DayStats/WeekStats/MonthStats, halving reported monthly savings; fix by reusing MonthStats::savings_pct and add regression tests.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/economics.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:performancebuggood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions