juspay / juspay/decision-engine

Sticky routing: record successes on update-gateway-score

Open
#415 0 comments 0 reactions 1 assignee Claimed by @prajjwalkumar17 View on GitHub
Dominant language
Rust
Stars
128
Forks
36
Avg merge
1d 15h
Merged PRs (30d)
34

Description

Part of #393 (sticky routing). **Status: implemented** in #420 (commit `5c542ea`), pending review/merge.

`POST /update-gateway-score` gains three optional, backward-compatible fields:

```jsonc
{ "customerId": "cust_123", "paymentMethod": "INTERAC", "paymentMethodType": "RTP", ... }
```

- Payload wins; the decide-time `gateway_scoring_data_{payment_id}` snapshot (which now also stashes `customerId`) is the fallback — so callers only need the fields when success webhooks can outlive the snapshot's 30-minute TTL.
- **Two-pass hook** in `check_and_update_gateway_score_`: a payload-only pass runs *before* the snapshot fetch (a CHARGED webhook hours late still counts), the snapshot pass after.
- Writes only on **CHARGED / AUTHORIZED / PARTIAL_CHARGED** — the engine's wider success set includes lifecycle statuses (VOIDED, AUTO_REFUNDED, CAPTURE_FAILED, …) that would let a late webhook re-count an earlier attempt's connector. Retries are correct by construction: fail-on-A writes nothing, success-on-B increments B.
- **No dedupe, by design**: update-gateway-score is the source of truth — every event counts, N times if sent N times (matching the engine default SR behavior; its feedback locks are opt-in per merchant).
- Bug fixed en route: the GSM healthy-failure early-return now fires on failures only — previously a success carrying `errorInfo` skipped both the SR reward and any snapshot-based work.
- Gated by the `sticky_routing_enabled` FeatureConf; a sticky write failure is logged, never surfaced to the caller. openapi + api-refs updated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.