Repository navigation
Conversation
📊 Automated PR Analysis
SummaryFixes gain analytics so negative net savings (regressions) are preserved as signed values throughout history, summary, command/day/period, JSON/CSV export, and quota estimates instead of being clamped to zero or hidden in some views. Adds a new 'Regressions' section listing top net-losing commands, fixes loss bar rendering in graphs, and updates cc-economics to carry signed savings consistently, with no schema migration required. Review Checklist
Linked issues: #3702 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
yeahjack
marked this pull request as ready for review
October 4, 2026 20:22
Contributor
Author
yeahjack
force-pushed
the
fix/gain-signed-net-savings
branch
from
October 19, 2026 10:25
ed6252c to
5ee3b9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3702.
Tracker::recordalready stores negative savings on currentdevelop, but gain's readers disagree: the headline clamps each row, while command/day/period/history readers clamp their aggregates. A saving of100 → 50followed by an expansion of100 → 200consequently reports +50 in the headline and 0 elsewhere instead of the real net −50 (−25%).This change keeps signed token deltas throughout the reporting path:
i64for saved-token fields in history, summary, command/day groups, and daily/weekly/monthly statistics; retain existing unsigned input/output counts--62% (0)Zero-input records retain their signed token delta with a finite 0% rate. Existing SQLite INTEGER columns already support signed values: no schema migration, version bump, or historical rewrite is needed. Rows that older versions already stored with clamped zero savings remain unchanged; this limitation is documented.
Scope and related work
This branch starts directly from
developatc356374, independently of #4435. It does not alter filters, command output, hooks, baseline/window accounting, or token-estimate caps. Intentionally expanded diagnostic output remains intact.The history-sign correction overlaps the narrow display fix in #2818. #3943's estimate-cap/baseline work remains separate; subsequent migrations should preserve signed deltas rather than reinstate a zero floor.
Verification
cargo fmt --all -- --checkcargo clippy --locked --all-targetscargo test --locked --all: 4,127 passed, 0 failed, 8 pre-existing ignoredcargo build --locked --releaseand isolated real-command smoke checkgit diff --checkand repository test-presence checkCI run 37140636125 passed all 10 jobs on
f94cd9785bbb37d5d9eeec34ca3d182727f41287, including Linux/macOS/Windows tests, benchmark, lint and security gates. CLA passed; the conditional target-branch check was skipped. This PR is ready for review.