Skip to content

Feat(euclid): Hyperswitch integration with decision engine #8000

@prajjwalkumar17

Description

@prajjwalkumar17

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.

How did you test it?

Here is the complete testing guidelines.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions