FAILURE MAP
← Case archive

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

Surge multiplier applied to the booking fee · case 01

At 2.5x surge the flat booking fee becomes 2.5 times larger.

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

ROOT CAUSE

The booking fee is folded into the surged core.

VERIFIED REPAIR

Surge only base, distance and time; add the booking fee afterwards.

Unsuccessful approach: Surging tolls into the core also double-charges them when they are passed through.

Case contract

Cents throughout. Surge (tenths) multiplies only base+distance+time, rounded half up. A percentage promo discounts the surged amount (floor), capped at promo cap cents. The booking fee is added after the discount. Tax (basis points, rounded half up) applies to surged - discount + booking fee; tolls and airport fees are passed through untaxed and unsurged.

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(parts, surge, promo, tax_bp):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    core = parts['base'] + parts['distance'] + parts['time'] + parts['booking_fee']
    surged = half_up(core * surge, 10)
    disc = 0
    if promo:
        disc = min(surged * promo['pct'] // 100, promo['cap'])
    sub = surged - disc
    tax = half_up(sub * tax_bp, 10000)
    total = sub + tax + parts['tolls'] + parts['airport_fee']
    return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1778, 'time': 866, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1084, 'time': 371, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2720, 'time': 873, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2506, 'time': 646, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1416, 'time': 612, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 709, 'time': 156, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2828, 'time': 171, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1428, 'time': 657, 'tolls': 690}, 17,
    None, 825],
   {'discount': 0, 'surged': 3800, 'tax': 328, 'total': 4993}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 713, 'time': 323, 'tolls': 375}, 15, None,
    625],
   {'discount': 0, 'surged': 1779, 'tax': 122, 'total': 2451}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 998, 'time': 460, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2412, 'tax': 219, 'total': 3371}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1810, 'time': 373, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3650, 'tax': 365, 'total': 4510}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1451, 'time': 384, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 2085, 'tax': 0, 'total': 2080}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 765, 'time': 379, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 970, 'surged': 1941, 'tax': 0, 'total': 1471}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1362, 'time': 592, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3306, 'tax': 0, 'total': 3301})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1423, 'time': 494, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2600, 'tax': 111, 'total': 2761}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 879, 'time': 747, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3189, 'tax': 343, 'total': 4647}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 660, 'time': 472, 'tolls': 690}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3455, 'tax': 185, 'total': 3830}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2852, 'time': 398, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 8500, 'tax': 850, 'total': 9845}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 706, 'time': 406, 'tolls': 0}, 10, None,
    1000],
   {'discount': 0, 'surged': 1362, 'tax': 136, 'total': 1498}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2282, 'time': 527, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2959, 'tax': 246, 'total': 2705}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 294, 'time': 652, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 224, 'total': 2464})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 748, 'time': 320, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1582, 'tax': 110, 'total': 1867}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 336, 'time': 837, 'tolls': 375}, 25, None,
    1000],
   {'discount': 0, 'surged': 3308, 'tax': 331, 'total': 4014}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1861, 'time': 607, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 6795, 'tax': 404, 'total': 6874}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 251, 'time': 580, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 736, 'surged': 1472, 'tax': 46, 'total': 782}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2510, 'time': 135, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4193, 'tax': 0, 'total': 4193}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1629, 'time': 264, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3215, 'tax': 265, 'total': 3975}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1916, 'time': 473, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2539, 'tax': 154, 'total': 1693})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2485, 'time': 638, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3928, 'tax': 225, 'total': 4328}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2937, 'time': 390, 'tolls': 690}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5911, 'tax': 491, 'total': 6092}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2487, 'time': 507, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 4716, 'tax': 0, 'total': 4391}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2216, 'time': 595, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5204, 'tax': 0, 'total': 4704}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2675, 'time': 665, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5235, 'tax': 349, 'total': 4584}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2698, 'time': 462, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5797, 'tax': 396, 'total': 5693}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1857, 'time': 629, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3954, 'tax': 0, 'total': 3454})]]
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: booking fee surged{'discount': 5, 'surged': 4454, 'tax': 445, 'total': 5394}{'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}Failed
partial repair probe: booking fee surged{'discount': 5, 'surged': 3315, 'tax': 207, 'total': 4207}{'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}Failed
second regression{'discount': 5, 'surged': 6132, 'tax': 0, 'total': 6127}{'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}Failed
normal control 1{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}Passed
normal control 2{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}Passed
normal control 3{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}Passed
normal control 4{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}Passed

SHA-256 / 942e290d8bde45c94aa8237e6abeafc6d551a2a468d184b96b0aa20f00518910

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(parts, surge, promo, tax_bp):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    core = parts['base'] + parts['distance'] + parts['time'] + parts['tolls']
    surged = half_up(core * surge, 10)
    disc = 0
    if promo:
        disc = min(surged * promo['pct'] // 100, promo['cap'])
    sub = surged - disc + parts['booking_fee']
    tax = half_up(sub * tax_bp, 10000)
    total = sub + tax + parts['tolls'] + parts['airport_fee']
    return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1778, 'time': 866, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1084, 'time': 371, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2720, 'time': 873, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2506, 'time': 646, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1416, 'time': 612, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 709, 'time': 156, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2828, 'time': 171, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1428, 'time': 657, 'tolls': 690}, 17,
    None, 825],
   {'discount': 0, 'surged': 3800, 'tax': 328, 'total': 4993}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 713, 'time': 323, 'tolls': 375}, 15, None,
    625],
   {'discount': 0, 'surged': 1779, 'tax': 122, 'total': 2451}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 998, 'time': 460, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2412, 'tax': 219, 'total': 3371}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1810, 'time': 373, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3650, 'tax': 365, 'total': 4510}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1451, 'time': 384, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 2085, 'tax': 0, 'total': 2080}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 765, 'time': 379, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 970, 'surged': 1941, 'tax': 0, 'total': 1471}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1362, 'time': 592, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3306, 'tax': 0, 'total': 3301})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1423, 'time': 494, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2600, 'tax': 111, 'total': 2761}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 879, 'time': 747, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3189, 'tax': 343, 'total': 4647}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 660, 'time': 472, 'tolls': 690}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3455, 'tax': 185, 'total': 3830}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2852, 'time': 398, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 8500, 'tax': 850, 'total': 9845}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 706, 'time': 406, 'tolls': 0}, 10, None,
    1000],
   {'discount': 0, 'surged': 1362, 'tax': 136, 'total': 1498}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2282, 'time': 527, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2959, 'tax': 246, 'total': 2705}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 294, 'time': 652, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 224, 'total': 2464})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 748, 'time': 320, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1582, 'tax': 110, 'total': 1867}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 336, 'time': 837, 'tolls': 375}, 25, None,
    1000],
   {'discount': 0, 'surged': 3308, 'tax': 331, 'total': 4014}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1861, 'time': 607, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 6795, 'tax': 404, 'total': 6874}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 251, 'time': 580, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 736, 'surged': 1472, 'tax': 46, 'total': 782}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2510, 'time': 135, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4193, 'tax': 0, 'total': 4193}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1629, 'time': 264, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3215, 'tax': 265, 'total': 3975}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1916, 'time': 473, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2539, 'tax': 154, 'total': 1693})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2485, 'time': 638, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3928, 'tax': 225, 'total': 4328}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2937, 'time': 390, 'tolls': 690}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5911, 'tax': 491, 'total': 6092}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2487, 'time': 507, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 4716, 'tax': 0, 'total': 4391}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2216, 'time': 595, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5204, 'tax': 0, 'total': 4704}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2675, 'time': 665, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5235, 'tax': 349, 'total': 4584}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2698, 'time': 462, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5797, 'tax': 396, 'total': 5693}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1857, 'time': 629, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3954, 'tax': 0, 'total': 3454})]]
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: booking fee surged{'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}{'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}Passed
partial repair probe: booking fee surged{'discount': 5, 'surged': 4072, 'tax': 270, 'total': 5272}{'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}Failed
second regression{'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}{'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}Passed
normal control 1{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}Passed
normal control 2{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}Passed
normal control 3{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}Passed
normal control 4{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}Passed

SHA-256 / fbc7ca1392b17b8ee2b4c8d19c732a6fdfef14c2666b8f8b7508f0c910b4a1c0

3 / The verified repair

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

N = 1
observations = []
def solve(parts, surge, promo, tax_bp):
    def half_up(num, den):
        return (num * 2 + den) // (den * 2)
    core = parts['base'] + parts['distance'] + parts['time']
    surged = half_up(core * surge, 10)
    disc = 0
    if promo:
        disc = min(surged * promo['pct'] // 100, promo['cap'])
    sub = surged - disc + parts['booking_fee']
    tax = half_up(sub * tax_bp, 10000)
    total = sub + tax + parts['tolls'] + parts['airport_fee']
    return {'surged': surged, 'discount': disc, 'tax': tax, 'total': total}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1778, 'time': 866, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1084, 'time': 371, 'tolls': 690}, 17,
    {'cap': 5, 'pct': 15}, 625],
   {'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2720, 'time': 873, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2506, 'time': 646, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}),
  ('normal control 2',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1416, 'time': 612, 'tolls': 0}, 17,
    {'cap': 500, 'pct': 20}, 825],
   {'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 709, 'time': 156, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}),
  ('normal control 4',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2828, 'time': 171, 'tolls': 0}, 17, None,
    625],
   {'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 1428, 'time': 657, 'tolls': 690}, 17,
    None, 825],
   {'discount': 0, 'surged': 3800, 'tax': 328, 'total': 4993}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 713, 'time': 323, 'tolls': 375}, 15, None,
    625],
   {'discount': 0, 'surged': 1779, 'tax': 122, 'total': 2451}),
  ('second regression',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 998, 'time': 460, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 2412, 'tax': 219, 'total': 3371}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1810, 'time': 373, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3650, 'tax': 365, 'total': 4510}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1451, 'time': 384, 'tolls': 0}, 10,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 2085, 'tax': 0, 'total': 2080}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 765, 'time': 379, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 970, 'surged': 1941, 'tax': 0, 'total': 1471}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 1362, 'time': 592, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 0],
   {'discount': 5, 'surged': 3306, 'tax': 0, 'total': 3301})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 1423, 'time': 494, 'tolls': 375}, 12,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 1000, 'surged': 2600, 'tax': 111, 'total': 2761}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 879, 'time': 747, 'tolls': 375}, 17,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 3189, 'tax': 343, 'total': 4647}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 660, 'time': 472, 'tolls': 690}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3455, 'tax': 185, 'total': 3830}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2852, 'time': 398, 'tolls': 0}, 25,
    {'cap': 5, 'pct': 15}, 1000],
   {'discount': 5, 'surged': 8500, 'tax': 850, 'total': 9845}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 706, 'time': 406, 'tolls': 0}, 10, None,
    1000],
   {'discount': 0, 'surged': 1362, 'tax': 136, 'total': 1498}),
  ('normal control 3',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2282, 'time': 527, 'tolls': 0}, 10,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2959, 'tax': 246, 'total': 2705}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 294, 'time': 652, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 1000],
   {'discount': 500, 'surged': 2740, 'tax': 224, 'total': 2464})],
 [('regression: booking fee surged',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 748, 'time': 320, 'tolls': 0}, 12, None,
    625],
   {'discount': 0, 'surged': 1582, 'tax': 110, 'total': 1867}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 336, 'time': 837, 'tolls': 375}, 25, None,
    1000],
   {'discount': 0, 'surged': 3308, 'tax': 331, 'total': 4014}),
  ('second regression',
   [{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1861, 'time': 607, 'tolls': 0}, 25,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 6795, 'tax': 404, 'total': 6874}),
  ('normal control 1',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 251, 'time': 580, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 625],
   {'discount': 736, 'surged': 1472, 'tax': 46, 'total': 782}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2510, 'time': 135, 'tolls': 0}, 15, None,
    0],
   {'discount': 0, 'surged': 4193, 'tax': 0, 'total': 4193}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 1629, 'time': 264, 'tolls': 0}, 15,
    {'cap': 5, 'pct': 15}, 825],
   {'discount': 5, 'surged': 3215, 'tax': 265, 'total': 3975}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1916, 'time': 473, 'tolls': 0}, 10,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 2539, 'tax': 154, 'total': 1693})],
 [('regression: booking fee surged',
   [{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2485, 'time': 638, 'tolls': 0}, 12,
    {'cap': 500, 'pct': 20}, 625],
   {'discount': 500, 'surged': 3928, 'tax': 225, 'total': 4328}),
  ('partial repair probe: booking fee surged',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2937, 'time': 390, 'tolls': 690}, 17,
    {'cap': 1000, 'pct': 50}, 1000],
   {'discount': 1000, 'surged': 5911, 'tax': 491, 'total': 6092}),
  ('second regression',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2487, 'time': 507, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 4716, 'tax': 0, 'total': 4391}),
  ('normal control 1',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2216, 'time': 595, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 0],
   {'discount': 1000, 'surged': 5204, 'tax': 0, 'total': 4704}),
  ('normal control 2',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2675, 'time': 665, 'tolls': 0}, 15,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5235, 'tax': 349, 'total': 4584}),
  ('normal control 3',
   [{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 2698, 'time': 462, 'tolls': 0}, 17,
    {'cap': 1000, 'pct': 50}, 825],
   {'discount': 1000, 'surged': 5797, 'tax': 396, 'total': 5693}),
  ('normal control 4',
   [{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1857, 'time': 629, 'tolls': 0}, 15,
    {'cap': 500, 'pct': 20}, 0],
   {'discount': 500, 'surged': 3954, 'tax': 0, 'total': 3454})]]
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: booking fee surged{'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}{'discount': 5, 'surged': 4191, 'tax': 436, 'total': 5297}Passed
partial repair probe: booking fee surged{'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}{'discount': 5, 'surged': 2899, 'tax': 196, 'total': 4025}Passed
second regression{'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}{'discount': 5, 'surged': 5765, 'tax': 0, 'total': 6005}Passed
normal control 1{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}{'discount': 500, 'surged': 3962, 'tax': 216, 'total': 4178}Passed
normal control 2{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}{'discount': 500, 'surged': 3703, 'tax': 264, 'total': 3967}Passed
normal control 3{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}{'discount': 5, 'surged': 2538, 'tax': 209, 'total': 2742}Passed
normal control 4{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}{'discount': 0, 'surged': 5523, 'tax': 345, 'total': 6368}Passed

SHA-256 / d26f991998558c82ef34e19ebe46d0ab56a17347790ee5e458fadbf7558e3751

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:39.847051+00:00.

Case digest / ea1aceb181855ca6b737543651a716f861eb12e4d56e769dad73f9d423367220