feat: adding more dimensional granularity for scoring #106
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the SRv3 scoring engine by adding four new dimensions—card network, currency, auth type, and card bin—to both the scoring lookup functions and the Redis key generation logic.
- Extract and propagate new parameters (
cardSwitchProvider,card_isin,currency,authType) through all SRv3 scoring flows - Extend
get_sr_v3_*andget_sr_v3_sub_level_input_configto filter by the new dimensions - Update
get_unified_sr_keyto append optional fields when present, with a legacy fallback when none are provided
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/feedback/gateway_selection_scoring_v3/flow.rs | Extract new parameters in getSrV3MerchantBucketSize and pass them to get_sr_v3_bucket_size |
| src/feedback/gateway_scoring_service.rs | Inject new parameters into get_sr_v3_latency_threshold calls |
| src/decider/gatewaydecider/utils.rs | Update signatures of all get_sr_v3_* functions, add is_sr_v3_config_match, extend key gen |
| src/decider/gatewaydecider/types.rs | Add cardIsIn, cardSwitchProvider, currency fields to GatewayScoringData and state |
| src/decider/gatewaydecider/gw_scoring.rs | Pass new parameters into hedging, bucket size, reset factor, and extra‐score methods |
Comments suppressed due to low confidence (2)
src/decider/gatewaydecider/utils.rs:1565
- [nitpick] All
get_sr_v3_*functions take ownedOption<String>parameters and clone them in every call. To avoid repeated allocations, consider passing&Option<String>and using references for matching.
card_network: Option<String>,
src/decider/gatewaydecider/utils.rs:2461
- [nitpick] The legacy-fallback branch in
get_unified_sr_keyis important for backward compatibility. Adding a comment or docblock to explain why and when this fallback is used would help future maintainers.
if card_network.is_none() && card_isin.is_none() && currency.is_none() && auth_type.is_none() {
jagan-jaya
requested changes
Jul 22, 2025
jagan-jaya
requested changes
Jul 23, 2025
jagan-jaya
previously approved these changes
Jul 28, 2025
prajjwalkumar17
previously approved these changes
Jul 28, 2025
3402e3f
…er flow and related structures
PriyanshuC132
approved these changes
Jul 28, 2025
jagan-jaya
approved these changes
Jul 28, 2025
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.
The decision engine currently supports only payment_method and payment_method_type.
This pr also adds a function
config_sr_dimensionswhich allows us to configure dimensions on the merchant levelCreated a new
service_configurationSR_DIMENSION_CONFIG_merchant_123which will look like{"merchant_id":"merchant_1752591820","fields":["paymentInfo.currency","paymentInfo.country","paymentInfo.auth_type"]}Request (config_sr_dimensions)
Response (config_sr_dimensions)
If the SR Dimension is configured correctly
If the SR Dimension is not configured correctly
The current
get_unified_sr_keyfunction is used for creating the keys for the RedisBut in the current setup
So that means
get_unified_sr_keyfunction is only creating new keys based on pm and pmt viaintercalate_without_empty_string("_", &base_key)How do I test it?
so here
visaUSDOTP424242NLSo the keys that are generated after these changes are
keys that are generated before these changes, with the same curl are(only have pm and pmt)
How do I test with config_sr_dimensions?
We will change the config for the merchant, let's remove the country from SR_DIMENSION_CONFIG_merchant_abcdefg
The country dimension is removed from SR_DIMENSION_CONFIG_merchant_1752591820
SR_DIMENSION_CONFIG_merchant_abcdefg | {"merchant_id":"merchant_abcdefg","fields":["paymentInfo.currency","paymentInfo.card_is_in","paymentInfo.auth_type","paymentInfo.card_network"]}