FAILURE MAP
← Case archive

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

Refund reduces the charge below the minimum fare · case 01

A short inefficient trip is refunded to almost nothing.

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

ROOT CAUSE

The refund is capped by the whole charge rather than the charge above the minimum.

VERIFIED REPAIR

Cap the refund at charged - minimum, never negative.

Unsuccessful approach: Capping by the minimum fare itself confuses the floor with the cap.

Case contract

Refund for inefficient routes: only when actual distance is more than 20% longer than optimal (actual*5 > optimal*6). Refund the whole extra distance at per_km (half up); refunds under 200 cents are not issued; the refund never takes the charge below the minimum fare. Return refund cents.

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(charged, actual_m, optimal_m, per_km, minimum):
    if actual_m * 5 <= optimal_m * 6:
        return 0
    refund = ((actual_m - optimal_m) * per_km * 2 + 1000) // 2000
    if refund < 200:
        return 0
    return min(refund, charged)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum fare floor', [700, 14402, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [700, 7500, 5000, 150, 700], 0),
  ('normal control 1', [1200, 10000, 10000, 100, 700], 0),
  ('normal control 2', [4000, 9600, 8000, 100, 700], 0),
  ('normal control 3', [4000, 6000, 5000, 100, 700], 0),
  ('normal control 4', [2500, 10100, 10000, 100, 700], 0)],
 [('regression: minimum fare floor', [700, 18001, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 15000, 10000, 150, 700], 750),
  ('second regression', [700, 24002, 12001, 100, 700], 0),
  ('normal control 1', [700, 14401, 12001, 100, 700], 0),
  ('normal control 2', [4000, 6001, 5000, 150, 700], 0),
  ('normal control 3', [1200, 5100, 5000, 150, 700], 0),
  ('normal control 4', [1200, 12000, 8000, 100, 700], 400)],
 [('regression: minimum fare floor', [1200, 24002, 12001, 150, 700], 500),
  ('partial repair probe: minimum fare floor', [700, 18001, 12001, 100, 700], 0),
  ('second regression', [4000, 24002, 12001, 150, 700], 1800),
  ('normal control 1', [700, 9600, 8000, 100, 700], 0),
  ('normal control 2', [4000, 10000, 5000, 100, 700], 500),
  ('normal control 3', [2500, 6000, 5000, 150, 700], 0),
  ('normal control 4', [4000, 14402, 12001, 150, 700], 360)],
 [('regression: minimum fare floor', [700, 7500, 5000, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 16000, 8000, 100, 700], 800),
  ('second regression', [2500, 20000, 10000, 100, 700], 1000),
  ('normal control 1', [1200, 15000, 10000, 100, 700], 500),
  ('normal control 2', [4000, 12000, 8000, 150, 700], 600),
  ('normal control 3', [4000, 12000, 8000, 100, 700], 400),
  ('normal control 4', [2500, 10000, 10000, 150, 700], 0)],
 [('regression: minimum fare floor', [1200, 16000, 8000, 100, 700], 500),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [1200, 24002, 12001, 150, 700], 500),
  ('normal control 1', [700, 12001, 12001, 100, 700], 0),
  ('normal control 2', [1200, 7500, 5000, 100, 700], 250),
  ('normal control 3', [1200, 14401, 12001, 100, 700], 0),
  ('normal control 4', [1200, 7500, 5000, 150, 700], 375)]]
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: minimum fare floor3600Failed
partial repair probe: minimum fare floor12001200Passed
second regression3750Failed
normal control 100Passed
normal control 200Passed
normal control 300Passed
normal control 400Passed

SHA-256 / f5e96469d05223c2749675ddbbe7645e1d9cd2b7c14043a929c2bf2a792313d9

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(charged, actual_m, optimal_m, per_km, minimum):
    if actual_m * 5 <= optimal_m * 6:
        return 0
    refund = ((actual_m - optimal_m) * per_km * 2 + 1000) // 2000
    if refund < 200:
        return 0
    return min(refund, minimum)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum fare floor', [700, 14402, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [700, 7500, 5000, 150, 700], 0),
  ('normal control 1', [1200, 10000, 10000, 100, 700], 0),
  ('normal control 2', [4000, 9600, 8000, 100, 700], 0),
  ('normal control 3', [4000, 6000, 5000, 100, 700], 0),
  ('normal control 4', [2500, 10100, 10000, 100, 700], 0)],
 [('regression: minimum fare floor', [700, 18001, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 15000, 10000, 150, 700], 750),
  ('second regression', [700, 24002, 12001, 100, 700], 0),
  ('normal control 1', [700, 14401, 12001, 100, 700], 0),
  ('normal control 2', [4000, 6001, 5000, 150, 700], 0),
  ('normal control 3', [1200, 5100, 5000, 150, 700], 0),
  ('normal control 4', [1200, 12000, 8000, 100, 700], 400)],
 [('regression: minimum fare floor', [1200, 24002, 12001, 150, 700], 500),
  ('partial repair probe: minimum fare floor', [700, 18001, 12001, 100, 700], 0),
  ('second regression', [4000, 24002, 12001, 150, 700], 1800),
  ('normal control 1', [700, 9600, 8000, 100, 700], 0),
  ('normal control 2', [4000, 10000, 5000, 100, 700], 500),
  ('normal control 3', [2500, 6000, 5000, 150, 700], 0),
  ('normal control 4', [4000, 14402, 12001, 150, 700], 360)],
 [('regression: minimum fare floor', [700, 7500, 5000, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 16000, 8000, 100, 700], 800),
  ('second regression', [2500, 20000, 10000, 100, 700], 1000),
  ('normal control 1', [1200, 15000, 10000, 100, 700], 500),
  ('normal control 2', [4000, 12000, 8000, 150, 700], 600),
  ('normal control 3', [4000, 12000, 8000, 100, 700], 400),
  ('normal control 4', [2500, 10000, 10000, 150, 700], 0)],
 [('regression: minimum fare floor', [1200, 16000, 8000, 100, 700], 500),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [1200, 24002, 12001, 150, 700], 500),
  ('normal control 1', [700, 12001, 12001, 100, 700], 0),
  ('normal control 2', [1200, 7500, 5000, 100, 700], 250),
  ('normal control 3', [1200, 14401, 12001, 100, 700], 0),
  ('normal control 4', [1200, 7500, 5000, 150, 700], 375)]]
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: minimum fare floor3600Failed
partial repair probe: minimum fare floor7001200Failed
second regression3750Failed
normal control 100Passed
normal control 200Passed
normal control 300Passed
normal control 400Passed

SHA-256 / 39cd29ce9daf8ee5c8dd7e86eaa877069eb40aecd15b7767f99f51d8cd394aa8

3 / The verified repair

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

N = 1
observations = []
def solve(charged, actual_m, optimal_m, per_km, minimum):
    if actual_m * 5 <= optimal_m * 6:
        return 0
    refund = ((actual_m - optimal_m) * per_km * 2 + 1000) // 2000
    if refund < 200:
        return 0
    return max(0, min(refund, charged - minimum))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: minimum fare floor', [700, 14402, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [700, 7500, 5000, 150, 700], 0),
  ('normal control 1', [1200, 10000, 10000, 100, 700], 0),
  ('normal control 2', [4000, 9600, 8000, 100, 700], 0),
  ('normal control 3', [4000, 6000, 5000, 100, 700], 0),
  ('normal control 4', [2500, 10100, 10000, 100, 700], 0)],
 [('regression: minimum fare floor', [700, 18001, 12001, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 15000, 10000, 150, 700], 750),
  ('second regression', [700, 24002, 12001, 100, 700], 0),
  ('normal control 1', [700, 14401, 12001, 100, 700], 0),
  ('normal control 2', [4000, 6001, 5000, 150, 700], 0),
  ('normal control 3', [1200, 5100, 5000, 150, 700], 0),
  ('normal control 4', [1200, 12000, 8000, 100, 700], 400)],
 [('regression: minimum fare floor', [1200, 24002, 12001, 150, 700], 500),
  ('partial repair probe: minimum fare floor', [700, 18001, 12001, 100, 700], 0),
  ('second regression', [4000, 24002, 12001, 150, 700], 1800),
  ('normal control 1', [700, 9600, 8000, 100, 700], 0),
  ('normal control 2', [4000, 10000, 5000, 100, 700], 500),
  ('normal control 3', [2500, 6000, 5000, 150, 700], 0),
  ('normal control 4', [4000, 14402, 12001, 150, 700], 360)],
 [('regression: minimum fare floor', [700, 7500, 5000, 150, 700], 0),
  ('partial repair probe: minimum fare floor', [2500, 16000, 8000, 100, 700], 800),
  ('second regression', [2500, 20000, 10000, 100, 700], 1000),
  ('normal control 1', [1200, 15000, 10000, 100, 700], 500),
  ('normal control 2', [4000, 12000, 8000, 150, 700], 600),
  ('normal control 3', [4000, 12000, 8000, 100, 700], 400),
  ('normal control 4', [2500, 10000, 10000, 150, 700], 0)],
 [('regression: minimum fare floor', [1200, 16000, 8000, 100, 700], 500),
  ('partial repair probe: minimum fare floor', [4000, 24002, 12001, 100, 700], 1200),
  ('second regression', [1200, 24002, 12001, 150, 700], 500),
  ('normal control 1', [700, 12001, 12001, 100, 700], 0),
  ('normal control 2', [1200, 7500, 5000, 100, 700], 250),
  ('normal control 3', [1200, 14401, 12001, 100, 700], 0),
  ('normal control 4', [1200, 7500, 5000, 150, 700], 375)]]
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: minimum fare floor00Passed
partial repair probe: minimum fare floor12001200Passed
second regression00Passed
normal control 100Passed
normal control 200Passed
normal control 300Passed
normal control 400Passed

SHA-256 / 9bd65fa88381c1620a4c900238a2422ec8ea43d2d5db76a757381a287c06025b

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

Case digest / 0cf799d98e873b733b93d0c7408efca694e59b99f279e1e1e06d2e156ec1b5df