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: 04dc14a93022d03d74b02ae244ee8bb8afa50c27
- Task ID: juspay__hyperswitch-8000
- Version: v1.114.0
TASK DESCRIPTION: Bug: Feat(euclid): Hyperswitch integration with decision engine
Description
This PR integrates the Euclid-based decision engine with Hyperswitch’s dynamic routing infrastructure. It enables dual routing logic: legacy DSL-based evaluation and decision-engine-backed configurations. The integration ensures routing algorithms can be authored, activated, and evaluated via Euclid and linked seamlessly to merchant profiles.
Outcomes
- Adds support for storing and linking decision-engine routing IDs (
decision_engine_routing_id) in the existingrouting_algorithmtable. - Enables creation and linking of Euclid routing configurations during algorithm creation and configuration linking flows.
- Enhances observability with logging and tracing of decision engine interactions.
- Preserves backward compatibility with existing static/dynamic routing mechanisms.
Diff Hunk Explanation
crates/api_models/src/routing.rs- Added
decision_engine_routing_idtoRoutingDictionaryRecordto expose the DE mapping in API responses. - Updated
RoutingAlgorithmKindwithPartialEqto aid in logic branching.
crates/diesel_models/src/routing_algorithm.rs- Included new optional field
decision_engine_routing_idto map to Euclid's algorithm record.
crates/diesel_models/src/schema.rs- Altered
routing_algorithmschema to includedecision_engine_routing_id VARCHAR(64).
crates/router/src/core/payments/routing.rs- Imported
perform_decision_euclid_routinginto static routing flow for test execution and future use.
crates/router/src/core/routing.rs- On routing creation, checks if the algorithm is a Euclid (Advanced) type, then creates it in the decision engine and stores the returned ID.
- On routing configuration linking, activates the respective routing config in the decision engine using
ActivateRoutingConfigRequest. - Enhances
retrieve_merchant_routing_dictionaryto fetch and append decision engine routing configs by profile ID.
crates/router/src/core/routing/transformers.rs- Ensures
decision_engine_routing_idis preserved and transformed when converting between internal and API models.
migrations/2025-05-08-102850_add_de_euclid_id_in_routing_algorithm_table/*.sql- Adds and removes the
decision_engine_routing_idcolumn in therouting_algorithmtable via Diesel migrations.
How did you test it?
Here is the complete testing guidelines.
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR integrates the Euclid-based decision engine with Hyperswitch’s dynamic routing infrastructure. It enables dual routing logic: legacy DSL-based evaluation and decision-engine-backed configurations. The integration ensures routing algorithms can be authored, activated, and evaluated via Euclid and linked seamlessly to merchant profiles.
Outcomes
- Adds support for storing and linking decision-engine routing IDs (
decision_engine_routing_id) in the existingrouting_algorithmtable. - Enables creation and linking of Euclid routing configurations during algorithm creation and configuration linking flows.
- Enhances observability with logging and tracing of decision engine interactions.
- Preserves backward compatibility with existing static/dynamic routing mechanisms.
Diff Hunk Explanation
crates/api_models/src/routing.rs- Added
decision_engine_routing_idtoRoutingDictionaryRecordto expose the DE mapping in API responses. - Updated
RoutingAlgorithmKindwithPartialEqto aid in logic branching.
crates/diesel_models/src/routing_algorithm.rs- Included new optional field
decision_engine_routing_idto map to Euclid's algorithm record.
crates/diesel_models/src/schema.rs- Altered
routing_algorithmschema to includedecision_engine_routing_id VARCHAR(64).
crates/router/src/core/payments/routing.rs- Imported
perform_decision_euclid_routinginto static routing flow for test execution and future use.
crates/router/src/core/routing.rs- On routing creation, checks if the algorithm is a Euclid (Advanced) type, then creates it in the decision engine and stores the returned ID.
- On routing configuration linking, activates the respective routing config in the decision engine using
ActivateRoutingConfigRequest. - Enhances
retrieve_merchant_routing_dictionaryto fetch and append decision engine routing configs by profile ID.
crates/router/src/core/routing/transformers.rs- Ensures
decision_engine_routing_idis preserved and transformed when converting between internal and API models.
migrations/2025-05-08-102850_add_de_euclid_id_in_routing_algorithm_table/*.sql- Adds and removes the
decision_engine_routing_idcolumn in therouting_algorithmtable via Diesel migrations.
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?
Here is the complete testing guidelines.
Migrations
ALTER TABLE routing_algorithm ADD COLUMN decision_engine_routing_id VARCHAR(64);Checklist
- 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
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 Euclid-based decision engine integration with Hyperswitch's dynamic routing infrastructure. Let me first understand the current state and create a focused plan for the implementation.
Assistant
Let me first explore the repository structure to understand the codebase better and locate the relevant files mentioned in the task.
Assistant
(no content)
Assistant
Let me also check the schema file and migration:
Assistant
(no content)
Assistant
Let me search for migration files more broadly:
Assistant
Let me look for a more specific migration pattern:
Assistant
Let me check what's in the routing core files mentioned in the task:
Assistant
(no content)
Assistant
Let me now examine the key files one by one to understand the current implementation. First, let's look at the API models for routing:
Assistant
Now let me check the diesel models for routing algorithm:
Assistant
Let me now look at the schema file to understand the current routing_algorithm table structure:
Assistant
Now let me check for the specific migration file that was referenced in the task. Based on the task description, it mentioned a migration file with the pattern
migrations/2025-05-08-102850_add_de_euclid_id_in_routing_algorithm_table/*.sql:Assistant
Let me search more broadly for any migration that might add the decision_engine_routing_id column:
Assistant
Let me examine the core routing module to understand how routing works currently:
Assistant
Now let me check the transformers file to understand how routing data is transformed:
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 →
claude-sonnet-4-5-20250929Compare side by side →