F-027: fix(history): round percentage conversion instead of truncating#27
Open
Sephyi wants to merge 1 commit intodevelopmentfrom
Open
F-027: fix(history): round percentage conversion instead of truncating#27Sephyi wants to merge 1 commit intodevelopmentfrom
Sephyi wants to merge 1 commit intodevelopmentfrom
Conversation
The commit-type percentage shown in the project-style prompt section was computed by truncating a float cast (`as u32`), which discards the fractional part — 66.666% became 66% instead of 67%. Replace the truncating cast with `.round() as u32` so percentages round to the nearest integer, matching what users reading the prompt would expect. Add a unit test covering the round-up case (2/3 → 67%) alongside the exact-percentage case (1/3 → 33%) to guard against accidental regression to truncation. Closes audit entry F-027 from #3.
There was a problem hiding this comment.
Pull request overview
This PR addresses audit finding F-027 by changing how commit-type distribution percentages are computed in the history prompt section: percentages are now rounded instead of truncated, improving accuracy in the generated style summary.
Changes:
- Update type distribution percentage calculation to use rounding (
round()) rather than truncation via float-to-int cast. - Add a regression test ensuring
to_prompt_section()reflects rounded percentages (e.g., 2/3 → 67%).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
fix(history): round percentage conversion instead of truncating.
Audit context
Closes audit entry F-027 from #3.
Verification
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-targets