feat(routing): add automatic kill switch for decision engine routing diffs
Adds is_volume to the decision_engine_euclid diff log so volume-split
driven (expected-random) diffs are distinguishable, and introduces a
per-profile Redis diff counter with a latched kill switch: once
non-volume evaluate_routing diffs cross the configured threshold within
the counter TTL window, the profile is automatically cut back to
Hyperswitch routing regardless of the configured routing_result_source.
- compare_and_log_result now logs is_volume and returns the comparison
outcome; volume detection covers advanced rules with volume_split
output
- diff counter: routing_decision_engine_{profile_id}_diff_count
(HINCRBY with TTL window); latch:
routing_decision_engine_{profile_id}_kill_switch (SET KEEPTTL, no
expiry; manual reset by deleting the key)
- enforcement inside get_routing_result_source, fail-open on Redis
errors so diff accounting never breaks payment routing
- hybrid path counts only DE static outcomes; dynamic selections (SR,
debit routing, unmapped DE approaches) are excluded from counting
- new [decision_engine_diff_kill_switch] config section (disabled by
default) and DECISION_ENGINE_ROUTING_DIFF /
DECISION_ENGINE_KILL_SWITCH_TRIGGERED metrics
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>