fix: normalize default weights to sum to 1.0 instead of 1.15 - #134
fix: normalize default weights to sum to 1.0 instead of 1.15#134ayushi2577 wants to merge 9 commits into
Conversation
|
Overall though, the bug and the reasoning behind the fix look legitimate but hey, can you please check these reviews out and just do a minor tweaks in your changes. The more tests and secure the code, the better it is, right? |
|
well i got confused in the issue numbers and for the test part i will do it soon and would be back with results |
|
Hey @Wahid7852 ,
for the testing part below are the screenshots Also, honestly the zero-sum edge case was a good catch, I hadn't thought about what happens when someone passes all zeros through config, that could've been a silent bug for a while |
ayushi2577
left a comment
There was a problem hiding this comment.
@Wahid7852, i went through all your comments and basically i have added validation for negative and zero-sum weights (both raise ValueError now), added the three tests you suggested, switched assertions to pytest.approx, and verified identity-heavy detections still work fine after the weight drop. Should be good to go! i have also attached the screenshots of tests in my last comment on pr
|
hey @ayushi2577 the validation and tests look good, before we merge, total_snap == 0 should be <= 0 to also catch edge cases where the sum is negative, and test_identity_heavy_detection uses score > 0.15 but the normalized identity weight is exactly 0.15 so that assertion would fail a correct result, needs to be tightened up. |
|
Fixed both |
|
Resaved as plain UTF-8 |
Wahid7852
left a comment
There was a problem hiding this comment.
final changes. promise.
|
Done, I have updated the error message to say 'snap weights', added the assert for the default path, and added a comment explaining why context and ip_rep aren't validated. |
i will do it after i check one thing |
|
@0-Shimanshu I request to review and merge it |
|
@Wahid7852 and @0-Shimanshu |
|
@ayushi2577 did you check the normalising function ? |
|
Yeah I checked , |
|
@0-Shimanshu merge? |
kinda confused about this cause decreasing value is not the right way to go i think here |



fixes issue - #116
Problem
The default
_weightsinscorer.pysummed to 1.15 instead of 1.0,inflating scores near the flag (0.25) and throttle (0.55) thresholds.
The
min(total, 1.0)clamp hid the issue for high scores but silentlycaused overly aggressive verdicts for borderline requests.
Also, the ConfigSnapshot override path only replaced payload, behavior,
and identity weights — leaving context and ip_rep at inflated defaults.
Fix
_weightsso they sum exactly to 1.0Fixes #128