FAILURE MAP
← Case archive

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

Earlier tips not counted toward the cap · case 01

Repeated tips on one trip exceed the cap.

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

ROOT CAUSE

Remaining room ignores tips already given.

VERIFIED REPAIR

Subtract prior tips from the cap and truncate the new tip to the room.

Unsuccessful approach: Accepting the full amount once any room exists still overshoots the cap.

Case contract

Tips can be added from trip end through 72 hours later inclusive (259200 s). Total tips per trip are capped at the larger of twice the fare or 50.00; a new tip is truncated to the remaining room, and rejected with "cap" when no room is left. Return [accepted cents, reason].

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(trip_end, tip_t, amount, fare, prior_tips):
    elapsed = tip_t - trip_end
    if elapsed < 0 or elapsed > 259200:
        return [0, 'window']
    cap = max(fare * 2, 5000)
    room = cap
    if room <= 0:
        return [0, 'cap']
    return [min(amount, room), 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prior tips room', [0, 259199, 500, 2400, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 1000], [4000, 'ok']),
  ('second regression', [0, 0, 6000, 2400, 1000], [4000, 'ok']),
  ('normal control 1', [0, 0, 500, 1200, 1000], [500, 'ok']),
  ('normal control 2', [0, -1, 6000, 1200, 1000], [0, 'window']),
  ('normal control 3', [0, 259199, 2000, 4000, 4800], [2000, 'ok']),
  ('normal control 4', [0, -1, 6000, 2400, 4800], [0, 'window'])],
 [('regression: prior tips room', [0, 259199, 6000, 4000, 4800], [3200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 3600, 6000, 1200, 0], [5000, 'ok']),
  ('normal control 1', [0, 3600, 2000, 4000, 1000], [2000, 'ok']),
  ('normal control 2', [0, 259201, 500, 4000, 0], [0, 'window']),
  ('normal control 3', [0, -1, 6000, 4000, 1000], [0, 'window']),
  ('normal control 4', [0, 0, 500, 2400, 0], [500, 'ok'])],
 [('regression: prior tips room', [0, 259200, 6000, 2400, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 0, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 2400, 4800], [200, 'ok']),
  ('normal control 1', [0, 0, 2000, 1200, 0], [2000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 3', [0, -1, 500, 2400, 0], [0, 'window']),
  ('normal control 4', [0, -1, 500, 2400, 8000], [0, 'window'])],
 [('regression: prior tips room', [0, 259200, 2000, 1200, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 500, 1200, 4800], [200, 'ok']),
  ('second regression', [0, 3600, 6000, 2400, 0], [5000, 'ok']),
  ('normal control 1', [0, 0, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 3', [0, 259201, 6000, 1200, 0], [0, 'window']),
  ('normal control 4', [0, 259199, 2000, 1200, 1000], [2000, 'ok'])],
 [('regression: prior tips room', [0, 259200, 500, 4000, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 1200, 8000], [0, 'cap']),
  ('normal control 1', [0, 0, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 2', [0, -1, 500, 1200, 0], [0, 'window']),
  ('normal control 3', [0, 0, 500, 2400, 1000], [500, 'ok']),
  ('normal control 4', [0, 259199, 6000, 4000, 1000], [6000, 'ok'])]]
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: prior tips room[500, 'ok'][200, 'ok']Failed
partial repair probe: prior tips room[5000, 'ok'][4000, 'ok']Failed
second regression[5000, 'ok'][4000, 'ok']Failed
normal control 1[500, 'ok'][500, 'ok']Passed
normal control 2[0, 'window'][0, 'window']Passed
normal control 3[2000, 'ok'][2000, 'ok']Passed
normal control 4[0, 'window'][0, 'window']Passed

SHA-256 / d7c8e6487b90c0084cbdb353a70a4278c3937fda43938c1b181e32a2b94c2b98

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(trip_end, tip_t, amount, fare, prior_tips):
    elapsed = tip_t - trip_end
    if elapsed < 0 or elapsed > 259200:
        return [0, 'window']
    cap = max(fare * 2, 5000)
    room = cap - prior_tips
    if room <= 0:
        return [0, 'cap']
    return [amount, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prior tips room', [0, 259199, 500, 2400, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 1000], [4000, 'ok']),
  ('second regression', [0, 0, 6000, 2400, 1000], [4000, 'ok']),
  ('normal control 1', [0, 0, 500, 1200, 1000], [500, 'ok']),
  ('normal control 2', [0, -1, 6000, 1200, 1000], [0, 'window']),
  ('normal control 3', [0, 259199, 2000, 4000, 4800], [2000, 'ok']),
  ('normal control 4', [0, -1, 6000, 2400, 4800], [0, 'window'])],
 [('regression: prior tips room', [0, 259199, 6000, 4000, 4800], [3200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 3600, 6000, 1200, 0], [5000, 'ok']),
  ('normal control 1', [0, 3600, 2000, 4000, 1000], [2000, 'ok']),
  ('normal control 2', [0, 259201, 500, 4000, 0], [0, 'window']),
  ('normal control 3', [0, -1, 6000, 4000, 1000], [0, 'window']),
  ('normal control 4', [0, 0, 500, 2400, 0], [500, 'ok'])],
 [('regression: prior tips room', [0, 259200, 6000, 2400, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 0, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 2400, 4800], [200, 'ok']),
  ('normal control 1', [0, 0, 2000, 1200, 0], [2000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 3', [0, -1, 500, 2400, 0], [0, 'window']),
  ('normal control 4', [0, -1, 500, 2400, 8000], [0, 'window'])],
 [('regression: prior tips room', [0, 259200, 2000, 1200, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 500, 1200, 4800], [200, 'ok']),
  ('second regression', [0, 3600, 6000, 2400, 0], [5000, 'ok']),
  ('normal control 1', [0, 0, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 3', [0, 259201, 6000, 1200, 0], [0, 'window']),
  ('normal control 4', [0, 259199, 2000, 1200, 1000], [2000, 'ok'])],
 [('regression: prior tips room', [0, 259200, 500, 4000, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 1200, 8000], [0, 'cap']),
  ('normal control 1', [0, 0, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 2', [0, -1, 500, 1200, 0], [0, 'window']),
  ('normal control 3', [0, 0, 500, 2400, 1000], [500, 'ok']),
  ('normal control 4', [0, 259199, 6000, 4000, 1000], [6000, 'ok'])]]
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: prior tips room[500, 'ok'][200, 'ok']Failed
partial repair probe: prior tips room[6000, 'ok'][4000, 'ok']Failed
second regression[6000, 'ok'][4000, 'ok']Failed
normal control 1[500, 'ok'][500, 'ok']Passed
normal control 2[0, 'window'][0, 'window']Passed
normal control 3[2000, 'ok'][2000, 'ok']Passed
normal control 4[0, 'window'][0, 'window']Passed

SHA-256 / 5caed3b8d4e58bbeddcfec891d73645b9394f39c397d1950112c8033372e0a78

3 / The verified repair

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

N = 1
observations = []
def solve(trip_end, tip_t, amount, fare, prior_tips):
    elapsed = tip_t - trip_end
    if elapsed < 0 or elapsed > 259200:
        return [0, 'window']
    cap = max(fare * 2, 5000)
    room = cap - prior_tips
    if room <= 0:
        return [0, 'cap']
    return [min(amount, room), 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prior tips room', [0, 259199, 500, 2400, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 1000], [4000, 'ok']),
  ('second regression', [0, 0, 6000, 2400, 1000], [4000, 'ok']),
  ('normal control 1', [0, 0, 500, 1200, 1000], [500, 'ok']),
  ('normal control 2', [0, -1, 6000, 1200, 1000], [0, 'window']),
  ('normal control 3', [0, 259199, 2000, 4000, 4800], [2000, 'ok']),
  ('normal control 4', [0, -1, 6000, 2400, 4800], [0, 'window'])],
 [('regression: prior tips room', [0, 259199, 6000, 4000, 4800], [3200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 3600, 6000, 1200, 0], [5000, 'ok']),
  ('normal control 1', [0, 3600, 2000, 4000, 1000], [2000, 'ok']),
  ('normal control 2', [0, 259201, 500, 4000, 0], [0, 'window']),
  ('normal control 3', [0, -1, 6000, 4000, 1000], [0, 'window']),
  ('normal control 4', [0, 0, 500, 2400, 0], [500, 'ok'])],
 [('regression: prior tips room', [0, 259200, 6000, 2400, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 0, 6000, 2400, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 2400, 4800], [200, 'ok']),
  ('normal control 1', [0, 0, 2000, 1200, 0], [2000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 3', [0, -1, 500, 2400, 0], [0, 'window']),
  ('normal control 4', [0, -1, 500, 2400, 8000], [0, 'window'])],
 [('regression: prior tips room', [0, 259200, 2000, 1200, 4800], [200, 'ok']),
  ('partial repair probe: prior tips room', [0, 259200, 500, 1200, 4800], [200, 'ok']),
  ('second regression', [0, 3600, 6000, 2400, 0], [5000, 'ok']),
  ('normal control 1', [0, 0, 6000, 4000, 1000], [6000, 'ok']),
  ('normal control 2', [0, 3600, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 3', [0, 259201, 6000, 1200, 0], [0, 'window']),
  ('normal control 4', [0, 259199, 2000, 1200, 1000], [2000, 'ok'])],
 [('regression: prior tips room', [0, 259200, 500, 4000, 8000], [0, 'cap']),
  ('partial repair probe: prior tips room', [0, 259199, 6000, 1200, 0], [5000, 'ok']),
  ('second regression', [0, 0, 2000, 1200, 8000], [0, 'cap']),
  ('normal control 1', [0, 0, 6000, 4000, 0], [6000, 'ok']),
  ('normal control 2', [0, -1, 500, 1200, 0], [0, 'window']),
  ('normal control 3', [0, 0, 500, 2400, 1000], [500, 'ok']),
  ('normal control 4', [0, 259199, 6000, 4000, 1000], [6000, 'ok'])]]
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: prior tips room[200, 'ok'][200, 'ok']Passed
partial repair probe: prior tips room[4000, 'ok'][4000, 'ok']Passed
second regression[4000, 'ok'][4000, 'ok']Passed
normal control 1[500, 'ok'][500, 'ok']Passed
normal control 2[0, 'window'][0, 'window']Passed
normal control 3[2000, 'ok'][2000, 'ok']Passed
normal control 4[0, 'window'][0, 'window']Passed

SHA-256 / 82b1f0b24f880ed9c1b939fdc9aa253a7f70829e0efd8a102edd4bc201efc748

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

Case digest / d1e3a71369ed698082ac6ddab863b134b779165da5c36ec200efd2295cf36b37