SELTENLABS
Documentation

Cascade and routing

How the platform picks a provider among several of one kind and when it moves on to the next. The main rule: an action with an outside effect is never repeated.

Documentation sections

Why a cascade#

A vendor goes down, errs or gets blocked. If a fallback exists but a person switches to it during an incident, there is effectively none. The cascade switches by itself, with one condition: it must not repeat an action that already happened. A message sent twice is unpleasant; a payout made twice costs money.

Three rules#

RuleFor whatWhat it does
safeOperations without an outside effect or idempotent ones: list screening, AI text, opening a KYC case, the outbound proxy.Any failure moves the request to the next provider.
on_rejectOperations with an outside effect: an email, an SMS, a push, a deposit and a payout.To the next provider only after an explicit refusal before the effect. An unknown outcome and any other error stop the cascade.
noneGames and VPN: a game belongs to its supplier, a VPN profile lives on the server that issued it.No cascade: only the first usable one is tried and its error is returned as it is.

The outcome of an attempt and the decision#

For operations with an outside effect a connector must tell the outcomes apart itself: whether the next one may be tried depends on it. A payout example: the request went to provider A, the answer was lost, and it is unknown whether A paid. Paying through B could pay the player a second time, so the cascade stops and a person or a reconciliation decides. Had A answered refusal, or could not be reached, nothing happened and the payout goes to B.

What happened at the providerWhat it is called in the codeThe cascade for on_reject
Could not even connect, bad keys, a local validationCheckFailedmoves on
The vendor explicitly refused before acting: a recipient refused, a 4xx on a send, a payment declinedRejectedmoves on; it is not counted as a health failure of the vendor
The request may have arrived and the answer was lost: a read timeout, a drop after sending, a 5xxOutcomeUnknownstops
Any other error (a bug)an exceptionstops
A call with an outside effecta payout, an email, an SMSProvider Afirst by priorityIt answered, theoperation is doneDoneRefused beforean effect: Rejectedor CheckFailedThe outcome isunknownThe cascade stops:a second providercould repeat theeffectProvider Bnext by priorityList exhausted: 503no_provider_available
The cascade tree for operations with an outside effect. Highlighted: the path where the first provider answered.

Routes#

A route is bound to a purpose inside a category (email.system and email.marketing are routed independently). A route has: a project (or all projects), a connector, a priority (lower goes first), whether it is enabled, a weight (the traffic share inside one priority), conditions on country, currency, language and amount range, a note.

  • Which list is used. When a project has its own routes for a purpose, only those apply; otherwise the global list; when there are no routes at all the platform behaves as it did before routing (every usable connector in code order). A saved list whose routes are all disabled means no provider (503), not the old behaviour.
  • The order. Usable candidates are grouped by priority; inside a priority the order is a weighted random draw without replacement, so the first gets its share of traffic and the rest are fallbacks before the next priority.
  • A candidate is usable when the connector exists, is not planned, implements the needed contract, the route is enabled, the connector is built in or connected (not in error, not disabled, not unconfigured), the route's conditions match the request and its circuit breaker is not open. An unknown value (a player without a country) never matches a condition on that value.

The list is exhausted: a 503 no_provider_available answer with the list of attempts and the reasons candidates were skipped.

The circuit breaker#

Each connector has its own circuit breaker. After five failures in a row that happen within five minutes it opens: the connector is skipped for two minutes. Then one probe call is allowed: success closes the breaker, failure opens it again. An explicit refusal by a vendor is not a failure: the vendor answered. The thresholds are the settings routing_fail_threshold, routing_fail_window_seconds, routing_open_seconds.

A state change is written to the exchange log and the event bus (route.open, route.half_open, route.closed). Platform processes learn of it from the log within 5 seconds, and with Valkey at once: the failure counter is shared. Without Valkey everything works the same, only per process.

Capabilities and where they are wired#

The cascade does not work equally everywhere: for some capabilities it is wired into the platform, for others there are only rules and a dry run.

CapabilityCascade ruleWhere it is wired
kyc.identity
Identity verification
safewired
aml.screening
AML and sanctions screening
safea helper exists, nothing calls it
email.system
System email
on_rejectwired
email.marketing
Marketing email
on_rejectwired
sms.system
System SMS
on_rejectwired
sms.marketing
Marketing SMS
on_rejectwired
sms.otp
One-time codes by SMS
on_rejectrules and a dry run only
push.player
Push and messengers to players
on_rejectwired
ai.text
AI text generation
safea helper exists, nothing calls it
payments.deposit
Deposits
on_rejectrules and a dry run only
payments.payout
Payouts
on_rejectrules and a dry run only
proxy.outbound
Outbound proxy
saferules and a dry run only
vpn.staff
VPN for staff
nonerules and a dry run only
games.launch
Game launch
nonerules and a dry run only

Where it is set up#

There is no routes screen in the interface yet. Routes are set by a staff member with the integrations:edit right through the core API /api/admin/integrations/routing (it is not reachable with an external API key). Viewing takes the integrations:view right. Saving a list requires a comment and is written to the action log with the state before and after. The dry run POST /api/admin/integrations/routing/simulate calls nothing: it shows whom the platform would try and in what order for a given country, currency, language and amount. A breaker can be closed by hand.