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_0 (already cloned)
- Base commit: e637b214e348216d30c9af59cce85a1264badebf
- Task ID: juspay__hyperswitch-8157
- Version: v1.114.0
TASK DESCRIPTION: Bug: refactor(success_based): add support for exploration
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 support an "exploration percentage" parameter in success-based routing configurations and adds a "RoutingApproach" enum to define routing strategies. These changes span multiple files, including API specifications, Rust models, and protocol buffer definitions, ensuring end-to-end support for the new functionality.
New Feature: Exploration Percentage in Routing Configurations
- Added
exploration_percentparameter to theSuccessBasedRoutingConfigstruct in Rust models (crates/api_models/src/routing.rs) and updated its default implementation. [1] [2] - Modified the
updatemethod inSuccessBasedRoutingConfigBodyto handle updates to theexploration_percentfield. - Updated the gRPC client (
crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs) to include theexploration_percentfield in theCalSuccessRateConfigmapping. - Enhanced the protocol buffer definition (
proto/success_rate.proto) to includeexploration_percentas an optional field in theCalSuccessRateConfigmessage.
New Enum: Routing Approach
Assistant
I'll tackle this refactoring task to add support for exploration in success-based routing. Let me first understand the current implementation by examining the relevant files mentioned in the task description.
Assistant
Let me start by examining the current SuccessBasedRoutingConfig struct in the routing.rs file to understand the existing implementation.
Assistant
Now let me examine the gRPC client implementation to understand how the success rate config is currently handled:
Assistant
Now let me examine the protocol buffer definition to understand how the exploration_percent field should be added:
Assistant
Now let me check the OpenAPI specification to see where the exploration_percent should be added:
Assistant
(no content)
Assistant
Let me search more specifically in the yaml files:
Assistant
(no content)
Assistant
(no content)
Assistant
(no content)
Assistant
Let me check what files are in the api-reference directory:
Assistant
Great! Now let me examine the OpenAPI specification file to understand how to add the exploration_percent:
Assistant
Let me continue reading the YAML file to find the schemas:
Assistant
Let me find the components/schemas section:
Assistant
(no content)
Assistant
Let me look at the schemas section around line 639:
Assistant
Let me also look for CalGlobalSuccessRateConfig to understand the complete picture:
Assistant
Now I'll start making the required changes. First, let me update the SuccessBasedRoutingConfig in the routing.rs file to add the exploration_percent field:
Assistant
Now I'll modify the protocol buffer definition to add the exploration_percent field and RoutingApproach enum:
Assistant
Let me update the todo list and then make the necessary changes to the Rust code first:
Assistant
Now let me update the SuccessBasedRoutingConfig in the routing.rs file to add the exploration_percent field:
Assistant
Let me check the exact content of that struct again:
Assistant
(no content)
Assistant
Let me also update the default implementation for SuccessBasedRoutingConfig to include exploration_percent:
Assistant
Now I'll also update the update method for SuccessBasedRoutingConfigBody to handle the exploration_percent field:
Assistant
Let me now update the OpenAPI spec file to include the exploration_percent parameter:
Assistant
Let me update the CalGlobalSuccessRateConfig as well:
Assistant
Let me update the gRPC client code to handle the exploration_percent field. First, I'll examine the current ForeignTryFrom implementations:
Assistant
Let me also update the gRPC client code to handle the exploration_percent field. First let me read the rest of the file to understand how it's structured:
Assistant
Now let me update the ForeignTryFrom implementations to handle exploration_percent:
Assistant
Let me also update the CalGlobalSuccessRateConfig conversion:
Assistant
Let me try a different approach and create a script to make all the required changes at once. First, let me check if I can create a proper working directory structure to allow the file writes.
Let me also verify what changes I need to make and update the todo list:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.