You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_1 (already cloned)
- Base commit: 67a42f0c27157f876698982a6b5f0a1cd3e15ffb
- Task ID: juspay__hyperswitch-8240
- Version: v1.114.0
TASK DESCRIPTION: Bug: refactor(dynamic_routing): add support for shuffle on tie flag to success_based routing
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This pull request introduces a new feature to the routing configuration: the ability to shuffle results on a tie during exploitation. This feature is implemented across multiple files, including API specifications, Rust models, and protocol buffer definitions. Below is a summary of the most important changes grouped by theme.
Feature Addition: Shuffle on Tie During Exploitation
- API Specification Update: Added
shuffle_on_tie_during_exploitationto the routing configuration inapi-reference/hyperswitch_intelligent_router_open_api_spec.yml. This parameter enhances routing behavior during exploitation when multiple options have equal success rates. - Rust Model Updates:
- Updated the
SuccessBasedRoutingConfigdefault implementation incrates/api_models/src/routing.rsto includeshuffle_on_tie_during_exploitationwith a default value offalse. - Added
shuffle_on_tie_during_exploitationas an optional field in theSuccessBasedRoutingConfigBodystruct to allow API clients to configure this behavior. - Modified the
update_frommethod inSuccessBasedRoutingConfigBodyto handle updates to theshuffle_on_tie_during_exploitationfield.
- Updated the
- Protocol Buffer Update: Added
shuffle_on_tie_during_exploitationas an optional field in theCalSuccessRateConfigmessage definition inproto/success_rate.proto. This ensures compatibility with external services using gRPC. - gRPC Client Update: Incorporated the new
shuffle_on_tie_during_exploitationfield into theForeignTryFromimplementation forCalSuccessRateConfigincrates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs.
Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
How did you test it?
- Create merchant_account, api_key.
- Toggle SR for the default profile_created above
curl --location --request POST 'http://localhost:8080/account/merchant_1748681084/business_profile/pro_3gHXWoq1Xh3AKi6tNZV1/dynamic_routing/success_based/toggle?enable=dynamic_connector_selection' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: xyz'Check the
routing_algorithmtable forshuffle_on_tie_during_exploitationfield inalgorithm_datacolumn. By default it will be set tofalse- If you want to update it, hit below curl and activate that algorithm_id for profile.
curl --location --request PATCH 'http://localhost:8080/account/merchant_1749040696/business_profile/pro_IFPbNQgBfzPAsqXUSAll/dynamic_routing/success_based/config/routing_Vl1hWGUqg203J5WqeCtK' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: xyz' \ --data '{ "config": { "shuffle_on_tie_during_exploitation": true } } 'Check the
routing_algorithmtable forshuffle_on_tie_during_exploitationfield inalgorithm_datacolumn for the newly created algorithm above after updating. It should be set totrueChecklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
Summary by CodeRabbit
- New Features
- Introduced a new optional configuration parameter to control shuffle behavior during exploitation ties in success-based routing.
- Enhanced payment method information by indicating eligibility for recurring payments and added filtering options for payment methods.
- Documentation
- Updated API documentation and example requests to reflect the new configuration option and payment method changes.
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_1/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll help you implement the shuffle on tie flag for success-based routing in the hyperswitch repository. Let me start by creating a plan and then examine the relevant files to understand what needs to be changed.
Assistant
Let me start by examining the API specification file mentioned in the task description to understand the current routing configuration.
Assistant
Let me now look at the Rust models file to understand the SuccessBasedRoutingConfig:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →