fix(adapters): clamp reputation rates with coerceFraction (#91) - #118
Open
rudra496 wants to merge 1 commit into
Open
fix(adapters): clamp reputation rates with coerceFraction (#91)#118rudra496 wants to merge 1 commit into
rudra496 wants to merge 1 commit into
Conversation
|
@rudra496 is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
rudra496
force-pushed
the
fix/reputation-clamping-91
branch
from
August 26, 2026 10:52
87883c1 to
17349e5
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
Closes #91
This PR replaces the inline unclamped division (
coerceDecimal(...) / 100) forcompletionRateandonTimeDeliveryRateinadaptReputationwithcoerceFraction, and extendscoerceFractionto support an optional divisor parameter (defaulting to 1) and clamped fallback values.Changes
src/lib/utils.ts:coerceFraction(value, fallback = 0, divisor = 1)to accept an optional divisor parameter, ensuring raw percentage values (e.g."94","150","-20") are safely divided by 100 and strictly bounded to[0, 1].src/lib/adapters.ts:completionRateandonTimeDeliveryRateinadaptReputationthroughcoerceFraction(snapshot.completionRate, 0, 100)andcoerceFraction(snapshot.onTimeDeliveryPercentage, 0, 100).adaptBounty,adaptMilestone,adaptMaintenancePool): confirmed thatadaptBountyusescoercePercentage(clamped[0, 100]) andcoerceNonNegative, andadaptMilestone/adaptMaintenancePoolusecoerceNonNegative. No other unclamped fractions/percentages exist.src/lib/utils.test.tsforcoerceFractiondivisor support, upper/lower clamping, and non-numeric fallbacks.src/lib/adapters.test.tsverifying out-of-bounds inputs ("150" -> 1.0,"-20" -> 0.0), in-range inputs ("94" -> 0.94,"0" -> 0.0,"100" -> 1.0), corrupted strings (-> 0.0), and null snapshot behavior.Verification
npm test: 3/3 test suites passed (47/47 tests).npx tsc --noEmit: 0 type errors.npm run build: Turbopack production build succeeded cleanly.