Skip to content

Conversation

prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Apr 29, 2025

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 existing routing_algorithm table.
  • 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_id to RoutingDictionaryRecord to expose the DE mapping in API responses.
  • Updated RoutingAlgorithmKind with PartialEq to aid in logic branching.

crates/diesel_models/src/routing_algorithm.rs

  • Included new optional field decision_engine_routing_id to map to Euclid's algorithm record.

crates/diesel_models/src/schema.rs

  • Altered routing_algorithm schema to include decision_engine_routing_id VARCHAR(64).

crates/router/src/core/payments/routing.rs

  • Imported perform_decision_euclid_routing into 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_dictionary to fetch and append decision engine routing configs by profile ID.

crates/router/src/core/routing/transformers.rs

  • Ensures decision_engine_routing_id is 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_id column in the routing_algorithm table 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

@prajjwalkumar17 prajjwalkumar17 self-assigned this Apr 29, 2025
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner April 29, 2025 10:13
Copy link

semanticdiff-com bot commented Apr 29, 2025

@prajjwalkumar17 prajjwalkumar17 marked this pull request as draft May 5, 2025 20:02
@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label May 8, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label May 9, 2025
@prajjwalkumar17 prajjwalkumar17 marked this pull request as ready for review May 11, 2025 16:20
@prajjwalkumar17 prajjwalkumar17 requested a review from a team as a code owner May 11, 2025 16:20
@prajjwalkumar17 prajjwalkumar17 added A-routing Area: Routing and removed M-api-contract-changes Metadata: This PR involves API contract changes labels May 11, 2025
@prajjwalkumar17 prajjwalkumar17 added this to the May 2025 Release milestone May 11, 2025
@prajjwalkumar17 prajjwalkumar17 linked an issue May 11, 2025 that may be closed by this pull request
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label May 11, 2025
@Sarthak1799
Copy link
Contributor

Migration tests failing @prajjwalkumar17
Also fix the migration in PR desc, those should be to add the column.

Copy link
Contributor

@jagan-jaya jagan-jaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an alter table command in v2_migrations/2025-01-13-081847_drop_v1_columns/up.sql to remove the decision_engine_routing_id column in routing_algorithm.

Otherwise create down.sql also

jagan-jaya
jagan-jaya previously approved these changes May 13, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 14, 2025
Merged via the queue into main with commit 4087cd2 May 14, 2025
14 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the euclid_decision_engine branch May 14, 2025 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat(euclid): Hyperswitch integration with decision engine
4 participants