Skip to content

fix(lightweightRiskModel): fix duplicate quality check and add null g…#83

Open
Div1912 wants to merge 1 commit into
mericcintosun:mainfrom
Div1912:fix/riskmodel-duplicate-quality-check-and-missing-input-guard
Open

fix(lightweightRiskModel): fix duplicate quality check and add null g…#83
Div1912 wants to merge 1 commit into
mericcintosun:mainfrom
Div1912:fix/riskmodel-duplicate-quality-check-and-missing-input-guard

Conversation

@Div1912

@Div1912 Div1912 commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Two bugs fixed in src/lib/lightweightRiskModel.js:

Bug 1 - Duplicate totalPayments check inflates quality score

getDataQualityScore() awarded 25 points for totalPayments > 10 and another 25 points for totalPayments > 0. The second condition is always satisfied when the first is, so a wallet with >=10 payments can never score below 50/100 regardless of other data quality indicators (counterparties, asset diversity). The intent was to reward having any transactional activity alongside counterparty diversity. The last check has been changed to totalPayments > 0 && uniqueCounterparties > 0 to reflect that intent.

Bug 2 - No null guard in calculateRiskScore()

If metrics was null or undefined, the call would propagate into normalizeFeatures() and silently catch an error, falling through to fallbackRiskCalculation({}) with no logged context. An explicit null check is now added at the top of calculateRiskScore() so callers get a clear error message.

Files Changed

  • src/lib/lightweightRiskModel.js

Testing

  • getDataQualityScore({ totalPayments: 15, uniqueCounterparties: 0, assetDiversity: 0 }) should now return score: 25 (not 50).
    • calculateRiskScore(null) should log a clear error and return the fallback result.

@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the mericcintosun Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant