Skip to content

Execution Routing

Routing determines which execution path handles an opening, closing, or partial-closing request. Resolution is read-only; the resulting plan is then executed by the dealer execution layer.

The current implementation includes persistent route configuration, an immutable runtime cache, deterministic matching, a dry-run API, and guarded integration with market opening and pending activation.

RoutingContext
    ↓
ExecutionRoutingService::Resolve
    ↓ first matching route
RoutingExecutionPlan
    ├─ MANUAL_DEALER(timeout)  ─┐
    ├─ VIRTUAL_DEALER(timeout) ─┼─ ordered fallbacks
    ├─ INTERNAL                 └─ continue existing execution flow
    └─ REJECT                      reject request

GATEWAY is deliberately not a routing target. A dealer implementation may later decide to send an accepted request to an LP through a gateway.

Current stage

  • Routes and their steps are stored in bases/routing.db.
  • Runtime matching reads an immutable in-memory snapshot and never queries SQLite.
  • Routes are evaluated by priority DESC, id ASC.
  • The first enabled matching route wins.
  • If no route matches, the resolver returns a one-step INTERNAL default plan.
  • Administrative mutations publish a new snapshot only after the database transaction succeeds.
  • The dry-run resolver creates no trade and no Dealing Center request.
  • When [routing].execution_enabled is true, the plan handles OPEN, CLOSE, and PARTIAL_CLOSE.
  • MANUAL_DEALER creates a persistent request for a dealer pool.
  • VIRTUAL_DEALER evaluates an in-process automatic policy and produces ACCEPT, REJECT, or NEXT_STEP.
  • Manual request timeout advances through the saved route plan, including Virtual Dealer steps.
  • Imported restored positions bypass Routing.

Not active yet

  • delayed Virtual Dealer decisions;
  • requotes and policy-controlled price replacement;
  • gateway/LP execution selected by a dealer;
  • external transport subscription for virtual_dealer.decision audit events.

The current security-group execution fields are not read by Routing. Their migration or removal should happen when Dealing Center execution is introduced.

Execution switch

Routing execution is disabled by default and enabled at server startup through config.toml:

[routing]
execution_enabled = true

GetConfig exposes the effective value as routing_execution_enabled. Route CRUD and MngResolveRoute remain available while execution integration is disabled.

Access

Route mutations and route listing currently require an administrator session. Dry-run resolution is available to administrator, manager, and dealer sessions.