FAILURE MAP
← Case archive

FA-85726 / Ride-hailing fare and surge pricing / Open access

Conversion uses the inverted reverse rate · case 01

Converted fares are off by the bid/ask spread.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The reverse-direction pair is inverted instead of using the directed rate.

VERIFIED REPAIR

Use fx[FROM+TO] for conversion from the fare currency.

Unsuccessful approach: Using the reverse pair without inversion converts by the wrong rate entirely.

Case contract

Convert a fare to the payment currency with the directed rate fx[FROM+TO] = [num, den] (half up), then, for cash payments only, round half up to the payment currency cash step (CHF 5 centimes, SEK 100 ore, others 1). Card and wallet payments are not cash-rounded. Return the amount in minor units of the payment currency.

Why this case matters

Ride-hailing prices are computed per trip at scale; ordering, unit and boundary slips become systematic over- or under-charging.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        den, num = fx[pay_ccy + fare_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fx pair direction',
   [1999, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   180),
  ('partial repair probe: fx pair direction',
   [1234, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   14154),
  ('second regression',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1200),
  ('normal control 3',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1880),
  ('partial repair probe: fx pair direction',
   [1003, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('normal control 1',
   [747, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   747),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('partial repair probe: fx pair direction',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('second regression',
   [1003, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22900),
  ('partial repair probe: fx pair direction',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('second regression',
   [1003, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   943),
  ('normal control 1',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 2',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1005)],
 [('regression: fx pair direction',
   [3496, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   3286),
  ('partial repair probe: fx pair direction',
   [1999, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('second regression',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1999, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999),
  ('normal control 3',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: fx pair direction174180Failed
partial repair probe: fx pair direction1371114154Failed
second regression2221122929Failed
normal control 125022502Passed
normal control 212001200Passed
normal control 312341234Passed
normal control 425002500Passed

SHA-256 / 5f78d86c34b38a0cc87add5019c607646bd98c8d6a55b73c2913e70780ce68a4

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        num, den = fx[pay_ccy + fare_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fx pair direction',
   [1999, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   180),
  ('partial repair probe: fx pair direction',
   [1234, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   14154),
  ('second regression',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1200),
  ('normal control 3',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1880),
  ('partial repair probe: fx pair direction',
   [1003, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('normal control 1',
   [747, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   747),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('partial repair probe: fx pair direction',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('second regression',
   [1003, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22900),
  ('partial repair probe: fx pair direction',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('second regression',
   [1003, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   943),
  ('normal control 1',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 2',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1005)],
 [('regression: fx pair direction',
   [3496, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   3286),
  ('partial repair probe: fx pair direction',
   [1999, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('second regression',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1999, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999),
  ('normal control 3',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: fx pair direction22929180Failed
partial repair probe: fx pair direction11114154Failed
second regression18022929Failed
normal control 125022502Passed
normal control 212001200Passed
normal control 312341234Passed
normal control 425002500Passed

SHA-256 / da4565ef84d22ba71526c032e43f3486eae4ed6f7457e32ef3a30ef0ef97c1a1

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(fare_cents, fare_ccy, pay_ccy, method, fx, cash_step):
    amt = fare_cents
    if pay_ccy != fare_ccy:
        num, den = fx[fare_ccy + pay_ccy]
        amt = (amt * num * 2 + den) // (2 * den)
    if method == 'cash':
        step = cash_step.get(pay_ccy, 1)
        amt = (amt * 2 + step) // (2 * step) * step
    return amt
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: fx pair direction',
   [1999, 'SEK', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   180),
  ('partial repair probe: fx pair direction',
   [1234, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   14154),
  ('second regression',
   [1999, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1200),
  ('normal control 3',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 4',
   [2502, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2500)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1880),
  ('partial repair probe: fx pair direction',
   [1003, 'CHF', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1043),
  ('second regression',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('normal control 1',
   [747, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   747),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1234, 'EUR', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1160),
  ('partial repair probe: fx pair direction',
   [2502, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   28700),
  ('second regression',
   [1003, 'EUR', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1234, 'SEK', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'SEK', 'SEK', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)],
 [('regression: fx pair direction',
   [1999, 'EUR', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22900),
  ('partial repair probe: fx pair direction',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('second regression',
   [1003, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   943),
  ('normal control 1',
   [1003, 'CHF', 'CHF', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 2',
   [1234, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1234),
  ('normal control 3',
   [1003, 'EUR', 'EUR', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1005)],
 [('regression: fx pair direction',
   [3496, 'EUR', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   3286),
  ('partial repair probe: fx pair direction',
   [1999, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   22929),
  ('second regression',
   [1003, 'EUR', 'SEK', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   11504),
  ('normal control 1',
   [2502, 'EUR', 'EUR', 'card',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2502),
  ('normal control 2',
   [1999, 'EUR', 'EUR', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1999),
  ('normal control 3',
   [1999, 'SEK', 'SEK', 'cash',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   2000),
  ('normal control 4',
   [1003, 'CHF', 'CHF', 'wallet',
    {'CHFEUR': [104, 100], 'EURCHF': [94, 100], 'EURSEK': [1147, 100], 'SEKEUR': [9, 100]},
    {'CHF': 5, 'SEK': 100}],
   1003)]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: fx pair direction180180Passed
partial repair probe: fx pair direction1415414154Passed
second regression2292922929Passed
normal control 125022502Passed
normal control 212001200Passed
normal control 312341234Passed
normal control 425002500Passed

SHA-256 / fb823203d4267887244e54de2ca1f8d1c1331d362d97e23ce5573c7e7c690560

Verification & scope

A deterministic toy pricing contract stipulated for this example; it does not reproduce the pricing of any real ride-hailing operator or regulator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:43.091070+00:00.

Case digest / f315960773d2f4f363412ac36797bf2c9ae6c4ac0173aa9e6e73cc5292529611