FA-85391 / Ride-hailing fare and surge pricing / Open access
Percentage promo ignores its cap · case 01
A 50% promo takes 40.00 off an 80.00 ride despite a 10.00 cap.
ROOT CAUSE
The cap is never applied to the percentage discount.
VERIFIED REPAIR
Limit the discount to the cap in cents.
Unsuccessful approach: Treating the cap as dollars multiplies it by 100.
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']
surged = half_up(core * surge, 10)
disc = 0
if promo:
disc = surged * promo['pct'] // 100
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: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2070, 'time': 734, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1506, 'time': 265, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2171, 'time': 246, 'tolls': 375}, 17,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 855, 'time': 216, 'tolls': 0}, 12, None,
825],
{'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 599, 'time': 617, 'tolls': 0}, 12, None,
0],
{'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2589, 'time': 635, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 429, 'time': 564, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 825],
{'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2808, 'time': 350, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 5112, 'tax': 339, 'total': 4451}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1187, 'time': 97, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 3585, 'tax': 0, 'total': 2585}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 218, 'time': 836, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 1956, 'tax': 0, 'total': 2126}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2595, 'time': 377, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 8055, 'tax': 0, 'total': 8430}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 359, 'time': 804, 'tolls': 0}, 10, None,
625],
{'discount': 0, 'surged': 1313, 'tax': 93, 'total': 2081}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1650, 'time': 892, 'tolls': 690}, 17,
None, 1000],
{'discount': 0, 'surged': 4576, 'tax': 475, 'total': 6416}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2382, 'time': 551, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 7958, 'tax': 677, 'total': 10070})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2496, 'time': 616, 'tolls': 690}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3362, 'tax': 215, 'total': 3512}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2743, 'time': 287, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 4770, 'tax': 325, 'total': 4270}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2977, 'time': 212, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5159, 'tax': 0, 'total': 4659}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 530, 'time': 327, 'tolls': 690}, 10, None,
625],
{'discount': 0, 'surged': 1007, 'tax': 78, 'total': 2020}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 693, 'time': 420, 'tolls': 375}, 25,
None, 825],
{'discount': 0, 'surged': 3408, 'tax': 296, 'total': 4754}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 403, 'time': 448, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 330, 'surged': 1652, 'tax': 0, 'total': 1497}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 925, 'time': 819, 'tolls': 0}, 12, None,
625],
{'discount': 0, 'surged': 2273, 'tax': 157, 'total': 2675})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1887, 'time': 798, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4990, 'tax': 417, 'total': 4582}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2043, 'time': 744, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5163, 'tax': 0, 'total': 5528}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1583, 'time': 804, 'tolls': 0}, 25,
{'cap': 500, 'pct': 20}, 825],
{'discount': 500, 'surged': 6593, 'tax': 523, 'total': 7361}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 464, 'time': 114, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 247, 'surged': 1238, 'tax': 0, 'total': 1166}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 504, 'time': 655, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 3523, 'tax': 0, 'total': 4073}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 403, 'time': 175, 'tolls': 375}, 12,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 437, 'surged': 874, 'tax': 36, 'total': 1348}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2545, 'time': 164, 'tolls': 690}, 15, None,
625],
{'discount': 0, 'surged': 4439, 'tax': 277, 'total': 5406})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 592, 'time': 318, 'tolls': 690}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1160, 'tax': 72, 'total': 1917}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2992, 'time': 342, 'tolls': 690}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3484, 'tax': 0, 'total': 3674}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 920, 'time': 542, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 2740, 'tax': 242, 'total': 3347}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1845, 'time': 397, 'tolls': 375}, 15,
None, 1000],
{'discount': 0, 'surged': 3588, 'tax': 359, 'total': 4822}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2544, 'time': 666, 'tolls': 690}, 10,
None, 625],
{'discount': 0, 'surged': 3360, 'tax': 210, 'total': 4760}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 275, 'time': 747, 'tolls': 690}, 25, None,
1000],
{'discount': 0, 'surged': 3180, 'tax': 343, 'total': 4458}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2045, 'time': 515, 'tolls': 0}, 15, None,
0],
{'discount': 0, 'surged': 4215, 'tax': 0, 'total': 4215})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo cap | {'discount': 1527, 'surged': 3054, 'tax': 153, 'total': 2055} | {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634} | Failed |
| partial repair probe: promo cap | {'discount': 1010, 'surged': 2021, 'tax': 0, 'total': 1631} | {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641} | Failed |
| second regression | {'discount': 680, 'surged': 4534, 'tax': 403, 'total': 5307} | {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049} | Failed |
| normal control 1 | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | Passed |
| normal control 2 | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | Passed |
| normal control 3 | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | Passed |
| normal control 4 | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | Passed |
SHA-256 / abbc75e48e537266353844f7962317421dd546e39f590cec4537d699d3e51fb9
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']
surged = half_up(core * surge, 10)
disc = 0
if promo:
disc = min(surged * promo['pct'] // 100, promo['cap'] * 100)
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: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2070, 'time': 734, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1506, 'time': 265, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2171, 'time': 246, 'tolls': 375}, 17,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 855, 'time': 216, 'tolls': 0}, 12, None,
825],
{'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 599, 'time': 617, 'tolls': 0}, 12, None,
0],
{'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2589, 'time': 635, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 429, 'time': 564, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 825],
{'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2808, 'time': 350, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 5112, 'tax': 339, 'total': 4451}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1187, 'time': 97, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 3585, 'tax': 0, 'total': 2585}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 218, 'time': 836, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 1956, 'tax': 0, 'total': 2126}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2595, 'time': 377, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 8055, 'tax': 0, 'total': 8430}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 359, 'time': 804, 'tolls': 0}, 10, None,
625],
{'discount': 0, 'surged': 1313, 'tax': 93, 'total': 2081}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1650, 'time': 892, 'tolls': 690}, 17,
None, 1000],
{'discount': 0, 'surged': 4576, 'tax': 475, 'total': 6416}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2382, 'time': 551, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 7958, 'tax': 677, 'total': 10070})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2496, 'time': 616, 'tolls': 690}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3362, 'tax': 215, 'total': 3512}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2743, 'time': 287, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 4770, 'tax': 325, 'total': 4270}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2977, 'time': 212, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5159, 'tax': 0, 'total': 4659}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 530, 'time': 327, 'tolls': 690}, 10, None,
625],
{'discount': 0, 'surged': 1007, 'tax': 78, 'total': 2020}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 693, 'time': 420, 'tolls': 375}, 25,
None, 825],
{'discount': 0, 'surged': 3408, 'tax': 296, 'total': 4754}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 403, 'time': 448, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 330, 'surged': 1652, 'tax': 0, 'total': 1497}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 925, 'time': 819, 'tolls': 0}, 12, None,
625],
{'discount': 0, 'surged': 2273, 'tax': 157, 'total': 2675})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1887, 'time': 798, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4990, 'tax': 417, 'total': 4582}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2043, 'time': 744, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5163, 'tax': 0, 'total': 5528}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1583, 'time': 804, 'tolls': 0}, 25,
{'cap': 500, 'pct': 20}, 825],
{'discount': 500, 'surged': 6593, 'tax': 523, 'total': 7361}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 464, 'time': 114, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 247, 'surged': 1238, 'tax': 0, 'total': 1166}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 504, 'time': 655, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 3523, 'tax': 0, 'total': 4073}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 403, 'time': 175, 'tolls': 375}, 12,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 437, 'surged': 874, 'tax': 36, 'total': 1348}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2545, 'time': 164, 'tolls': 690}, 15, None,
625],
{'discount': 0, 'surged': 4439, 'tax': 277, 'total': 5406})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 592, 'time': 318, 'tolls': 690}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1160, 'tax': 72, 'total': 1917}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2992, 'time': 342, 'tolls': 690}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3484, 'tax': 0, 'total': 3674}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 920, 'time': 542, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 2740, 'tax': 242, 'total': 3347}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1845, 'time': 397, 'tolls': 375}, 15,
None, 1000],
{'discount': 0, 'surged': 3588, 'tax': 359, 'total': 4822}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2544, 'time': 666, 'tolls': 690}, 10,
None, 625],
{'discount': 0, 'surged': 3360, 'tax': 210, 'total': 4760}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 275, 'time': 747, 'tolls': 690}, 25, None,
1000],
{'discount': 0, 'surged': 3180, 'tax': 343, 'total': 4458}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2045, 'time': 515, 'tolls': 0}, 15, None,
0],
{'discount': 0, 'surged': 4215, 'tax': 0, 'total': 4215})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo cap | {'discount': 1527, 'surged': 3054, 'tax': 153, 'total': 2055} | {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634} | Failed |
| partial repair probe: promo cap | {'discount': 1010, 'surged': 2021, 'tax': 0, 'total': 1631} | {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641} | Failed |
| second regression | {'discount': 500, 'surged': 4534, 'tax': 421, 'total': 5505} | {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049} | Failed |
| normal control 1 | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | Passed |
| normal control 2 | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | Passed |
| normal control 3 | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | Passed |
| normal control 4 | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | Passed |
SHA-256 / cfb86725864289adefd98ff452526d8028988472d4bc9cabf8d2d6e0e28ff329
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: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2070, 'time': 734, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 1506, 'time': 265, 'tolls': 375}, 10,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 2171, 'time': 246, 'tolls': 375}, 17,
{'cap': 5, 'pct': 15}, 1000],
{'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 245, 'distance': 855, 'time': 216, 'tolls': 0}, 12, None,
825],
{'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 0, 'distance': 599, 'time': 617, 'tolls': 0}, 12, None,
0],
{'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 2589, 'time': 635, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 429, 'time': 564, 'tolls': 375}, 17,
{'cap': 500, 'pct': 20}, 825],
{'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2808, 'time': 350, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 5112, 'tax': 339, 'total': 4451}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 1187, 'time': 97, 'tolls': 0}, 25,
{'cap': 1000, 'pct': 50}, 0],
{'discount': 1000, 'surged': 3585, 'tax': 0, 'total': 2585}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 218, 'time': 836, 'tolls': 0}, 15,
{'cap': 5, 'pct': 15}, 0],
{'discount': 5, 'surged': 1956, 'tax': 0, 'total': 2126}),
('normal control 1',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2595, 'time': 377, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 8055, 'tax': 0, 'total': 8430}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 359, 'time': 804, 'tolls': 0}, 10, None,
625],
{'discount': 0, 'surged': 1313, 'tax': 93, 'total': 2081}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 175, 'distance': 1650, 'time': 892, 'tolls': 690}, 17,
None, 1000],
{'discount': 0, 'surged': 4576, 'tax': 475, 'total': 6416}),
('normal control 4',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 2382, 'time': 551, 'tolls': 690}, 25,
None, 825],
{'discount': 0, 'surged': 7958, 'tax': 677, 'total': 10070})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 2496, 'time': 616, 'tolls': 690}, 10,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 3362, 'tax': 215, 'total': 3512}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 2743, 'time': 287, 'tolls': 0}, 15,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 1000, 'surged': 4770, 'tax': 325, 'total': 4270}),
('second regression',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2977, 'time': 212, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5159, 'tax': 0, 'total': 4659}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 530, 'time': 327, 'tolls': 690}, 10, None,
625],
{'discount': 0, 'surged': 1007, 'tax': 78, 'total': 2020}),
('normal control 2',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 175, 'distance': 693, 'time': 420, 'tolls': 375}, 25,
None, 825],
{'discount': 0, 'surged': 3408, 'tax': 296, 'total': 4754}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 403, 'time': 448, 'tolls': 0}, 15,
{'cap': 500, 'pct': 20}, 0],
{'discount': 330, 'surged': 1652, 'tax': 0, 'total': 1497}),
('normal control 4',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 245, 'distance': 925, 'time': 819, 'tolls': 0}, 12, None,
625],
{'discount': 0, 'surged': 2273, 'tax': 157, 'total': 2675})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 1887, 'time': 798, 'tolls': 0}, 17,
{'cap': 1000, 'pct': 50}, 1000],
{'discount': 1000, 'surged': 4990, 'tax': 417, 'total': 4582}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 2043, 'time': 744, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 5163, 'tax': 0, 'total': 5528}),
('second regression',
[{'airport_fee': 500, 'base': 250, 'booking_fee': 245, 'distance': 1583, 'time': 804, 'tolls': 0}, 25,
{'cap': 500, 'pct': 20}, 825],
{'discount': 500, 'surged': 6593, 'tax': 523, 'total': 7361}),
('normal control 1',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 464, 'time': 114, 'tolls': 0}, 17,
{'cap': 500, 'pct': 20}, 0],
{'discount': 247, 'surged': 1238, 'tax': 0, 'total': 1166}),
('normal control 2',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 175, 'distance': 504, 'time': 655, 'tolls': 375}, 25, None,
0],
{'discount': 0, 'surged': 3523, 'tax': 0, 'total': 4073}),
('normal control 3',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 403, 'time': 175, 'tolls': 375}, 12,
{'cap': 1000, 'pct': 50}, 825],
{'discount': 437, 'surged': 874, 'tax': 36, 'total': 1348}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2545, 'time': 164, 'tolls': 690}, 15, None,
625],
{'discount': 0, 'surged': 4439, 'tax': 277, 'total': 5406})],
[('regression: promo cap',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 592, 'time': 318, 'tolls': 690}, 10,
{'cap': 5, 'pct': 15}, 625],
{'discount': 5, 'surged': 1160, 'tax': 72, 'total': 1917}),
('partial repair probe: promo cap',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 0, 'distance': 2992, 'time': 342, 'tolls': 690}, 10,
{'cap': 500, 'pct': 20}, 0],
{'discount': 500, 'surged': 3484, 'tax': 0, 'total': 3674}),
('second regression',
[{'airport_fee': 0, 'base': 150, 'booking_fee': 175, 'distance': 920, 'time': 542, 'tolls': 690}, 17,
{'cap': 500, 'pct': 20}, 1000],
{'discount': 500, 'surged': 2740, 'tax': 242, 'total': 3347}),
('normal control 1',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 1845, 'time': 397, 'tolls': 375}, 15,
None, 1000],
{'discount': 0, 'surged': 3588, 'tax': 359, 'total': 4822}),
('normal control 2',
[{'airport_fee': 500, 'base': 150, 'booking_fee': 0, 'distance': 2544, 'time': 666, 'tolls': 690}, 10,
None, 625],
{'discount': 0, 'surged': 3360, 'tax': 210, 'total': 4760}),
('normal control 3',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 245, 'distance': 275, 'time': 747, 'tolls': 690}, 25, None,
1000],
{'discount': 0, 'surged': 3180, 'tax': 343, 'total': 4458}),
('normal control 4',
[{'airport_fee': 0, 'base': 250, 'booking_fee': 0, 'distance': 2045, 'time': 515, 'tolls': 0}, 15, None,
0],
{'discount': 0, 'surged': 4215, 'tax': 0, 'total': 4215})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: promo cap | {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634} | {'discount': 1000, 'surged': 3054, 'tax': 205, 'total': 2634} | Passed |
| partial repair probe: promo cap | {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641} | {'discount': 1000, 'surged': 2021, 'tax': 0, 'total': 1641} | Passed |
| second regression | {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049} | {'discount': 5, 'surged': 4534, 'tax': 470, 'total': 6049} | Passed |
| normal control 1 | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | {'discount': 0, 'surged': 1465, 'tax': 141, 'total': 2351} | Passed |
| normal control 2 | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | {'discount': 0, 'surged': 1759, 'tax': 0, 'total': 2259} | Passed |
| normal control 3 | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | {'discount': 0, 'surged': 8435, 'tax': 710, 'total': 10510} | Passed |
| normal control 4 | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | {'discount': 388, 'surged': 1943, 'tax': 143, 'total': 2248} | Passed |
SHA-256 / e9c06ea04107c581c8fa6aeb730ba4331dcea3c8822809119fa3326e88d6236f
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.891157+00:00.
Case digest / 9a6bcd50b193926e95761e3ce1cf5e5710a94c8614894886332643ff8b595bf9