Skip to content

fix(economics): use tracked monthly savings percentage - #3973

Open
Raymondtaoo wants to merge 1 commit into
rtk-ai:developfrom
Raymondtaoo:fix/economics-monthly-savings-pct
Open

Raymondtaoo wants to merge 1 commit into
rtk-ai:developfrom
Raymondtaoo:fix/economics-monthly-savings-pct

Conversation

@Raymondtaoo

@Raymondtaoo Raymondtaoo commented Sep 10, 2026 •

Copy link
Copy Markdown

Closes #3972

Summary

  • use the savings percentage already calculated by MonthStats when constructing monthly economics
  • align monthly economics with the existing day and week paths

Regression coverage

  • verifies a monthly record with 100 input, 20 output, and 80 saved tokens retains the tracked 80% savings percentage
  • before this fix, the monthly economics formula reported 40% for that same record

Copilot AI lite review requested due to automatic review settings September 10, 2026 03:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change correctly aligns monthly savings percentage handling with day/week behavior and includes a targeted regression test covering the reported bug.

Pull request overview

This PR fixes monthly “economics” reporting by aligning PeriodEconomics::set_rtk_from_month with the existing day/week logic: it now uses the already-tracked MonthStats::savings_pct instead of recomputing the percentage with an incorrect denominator.

Changes:

  • Replace the monthly rtk_savings_pct recomputation with stats.savings_pct.
  • Add a focused regression test ensuring monthly economics preserves a tracked 80% savings percentage for a representative record.
File summaries
File Description
src/analytics/cc_economics.rs Uses tracked MonthStats::savings_pct for monthly economics and adds a regression test to prevent the prior under-reporting bug.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working rust economics labels Sep 10, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes monthly economics calculations to use the savings percentage already tracked by MonthStats instead of recomputing it incorrectly, aligning the monthly path with the existing day and week logic. Includes a regression test verifying a record with 100 input, 20 output, and 80 saved tokens correctly reports 80% savings instead of the previous incorrect 40%.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #3972


Analyzed 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

Labels

bug Something isn't working economics rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(economics): use tracked monthly savings percentage

2 participants