FAILURE MAP
← Case archive

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

Meter total truncated · case 01

The meter drops fractional cents instead of rounding.

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

ROOT CAUSE

The exact total is truncated.

THE FAILURE

The exact total is truncated.

Unsuccessful approach: Fraction round() is half-even and rounds exact halves down to even cents.

Case contract

A single-tariff taximeter bills each segment [seconds, meters] by distance when its speed is at least v m/s (meters >= v*seconds, so a zero-duration movement bills distance) and by time otherwise, never both. Charges accumulate exactly (per_km per 1000 m, per_hour per 3600 s) and the total is rounded half up to a cent once, then the flag fall is added.

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
from fractions import Fraction
N = 1
observations = []
def solve(segments, rate):
    acc = Fraction(0)
    for dt, dm in segments:
        if dm >= rate['v'] * dt:
            acc += Fraction(dm * rate['per_km'], 1000)
        else:
            acc += Fraction(dt * rate['per_hour'], 3600)
    cents = int(acc)
    return rate['flag'] + cents
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: final rounding',
   [[[5, 24], [0, 3], [10, 49], [1, 4]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 408),
  ('partial repair probe: final rounding',
   [[[0, 0], [30, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 333),
  ('second regression',
   [[[5, 28], [5, 25], [5, 55], [10, 49], [30, 153]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   464),
  ('normal control 1',
   [[[5, 0], [30, 60], [10, 7], [10, 7], [5, 55], [10, 50]],
    {'flag': 300, 'per_hour': 3900, 'per_km': 199, 'v': 5}],
   380),
  ('normal control 2', [[[0, 0]], {'flag': 300, 'per_hour': 4150, 'per_km': 245, 'v': 5}], 300),
  ('normal control 3', [[[5, 28]], {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}], 396),
  ('normal control 4',
   [[[10, 0], [10, 49], [10, 110], [5, 7], [10, 20], [5, 10]],
    {'flag': 390, 'per_hour': 3900, 'per_km': 245, 'v': 5}],
   460)],
 [('regression: final rounding',
   [[[10, 110], [10, 7], [1, 2]], {'flag': 390, 'per_hour': 3900, 'per_km': 245, 'v': 5}], 429),
  ('partial repair probe: final rounding',
   [[[0, 0], [30, 150]], {'flag': 390, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 425),
  ('second regression',
   [[[30, 149], [10, 7], [10, 110], [10, 53], [10, 110]],
    {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}],
   499),
  ('normal control 1',
   [[[5, 7], [10, 20], [10, 20], [30, 60], [0, 0], [30, 153]],
    {'flag': 300, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   392),
  ('normal control 2', [[[0, 0]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 300),
  ('normal control 3',
   [[[0, 0], [10, 50], [10, 49], [10, 7]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 422),
  ('normal control 4',
   [[[5, 25], [0, 0], [5, 0], [30, 150], [10, 50]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}],
   447)],
 [('regression: final rounding',
   [[[0, 3], [0, 0], [10, 110]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 326),
  ('partial repair probe: final rounding',
   [[[10, 20], [30, 60], [10, 0], [30, 150]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 385),
  ('second regression',
   [[[5, 55], [10, 7], [1, 8], [5, 55], [30, 330]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}],
   504),
  ('normal control 1', [[[5, 28]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 396),
  ('normal control 2', [[[5, 25], [30, 60]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 426),
  ('normal control 3', [[[5, 25], [1, 11]], {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}], 398),
  ('normal control 4',
   [[[5, 28], [30, 153], [10, 49], [0, 7], [1, 5], [1, 5]],
    {'flag': 300, 'per_hour': 3600, 'per_km': 199, 'v': 5}],
   349)],
 [('regression: final rounding', [[[1, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 245, 'v': 5}], 302),
  ('partial repair probe: final rounding',
   [[[30, 149]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 423),
  ('second regression',
   [[[1, 5], [30, 0], [30, 149], [10, 53]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 467),
  ('normal control 1', [[[1, 11], [0, 3]], {'flag': 390, 'per_hour': 4150, 'per_km': 245, 'v': 5}], 393),
  ('normal control 2',
   [[[1, 7], [30, 153], [10, 110], [10, 53], [1, 5]], {'flag': 300, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   380),
  ('normal control 3', [[[1, 2], [5, 24]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 306),
  ('normal control 4',
   [[[10, 49], [5, 24], [10, 7], [10, 7], [5, 7]], {'flag': 300, 'per_hour': 4150, 'per_km': 230, 'v': 5}],
   346)],
 [('regression: final rounding', [[[10, 50]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 312),
  ('partial repair probe: final rounding',
   [[[5, 25], [5, 25], [1, 0], [10, 7], [0, 0]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}],
   323),
  ('second regression', [[[1, 5], [10, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 312),
  ('normal control 1', [[[30, 150], [10, 49]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 435),
  ('normal control 2', [[[10, 50], [0, 7], [5, 10]], {'flag': 390, 'per_hour': 4150, 'per_km': 199, 'v': 5}],
   407),
  ('normal control 3', [[[30, 7]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 420),
  ('normal control 4', [[[0, 7]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 391)]]
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: final rounding407408Failed
partial repair probe: final rounding332333Failed
second regression463464Failed
normal control 1380380Passed
normal control 2300300Passed
normal control 3396396Passed
normal control 4460460Passed

SHA-256 / 6249f7a414d313b9513131c6baff9eb9ac3f0b9bc7fd9faade3da13b761a3eb3

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(segments, rate):
    acc = Fraction(0)
    for dt, dm in segments:
        if dm >= rate['v'] * dt:
            acc += Fraction(dm * rate['per_km'], 1000)
        else:
            acc += Fraction(dt * rate['per_hour'], 3600)
    cents = round(acc)
    return rate['flag'] + cents
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: final rounding',
   [[[5, 24], [0, 3], [10, 49], [1, 4]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 408),
  ('partial repair probe: final rounding',
   [[[0, 0], [30, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 333),
  ('second regression',
   [[[5, 28], [5, 25], [5, 55], [10, 49], [30, 153]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   464),
  ('normal control 1',
   [[[5, 0], [30, 60], [10, 7], [10, 7], [5, 55], [10, 50]],
    {'flag': 300, 'per_hour': 3900, 'per_km': 199, 'v': 5}],
   380),
  ('normal control 2', [[[0, 0]], {'flag': 300, 'per_hour': 4150, 'per_km': 245, 'v': 5}], 300),
  ('normal control 3', [[[5, 28]], {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}], 396),
  ('normal control 4',
   [[[10, 0], [10, 49], [10, 110], [5, 7], [10, 20], [5, 10]],
    {'flag': 390, 'per_hour': 3900, 'per_km': 245, 'v': 5}],
   460)],
 [('regression: final rounding',
   [[[10, 110], [10, 7], [1, 2]], {'flag': 390, 'per_hour': 3900, 'per_km': 245, 'v': 5}], 429),
  ('partial repair probe: final rounding',
   [[[0, 0], [30, 150]], {'flag': 390, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 425),
  ('second regression',
   [[[30, 149], [10, 7], [10, 110], [10, 53], [10, 110]],
    {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}],
   499),
  ('normal control 1',
   [[[5, 7], [10, 20], [10, 20], [30, 60], [0, 0], [30, 153]],
    {'flag': 300, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   392),
  ('normal control 2', [[[0, 0]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 300),
  ('normal control 3',
   [[[0, 0], [10, 50], [10, 49], [10, 7]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 422),
  ('normal control 4',
   [[[5, 25], [0, 0], [5, 0], [30, 150], [10, 50]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}],
   447)],
 [('regression: final rounding',
   [[[0, 3], [0, 0], [10, 110]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 326),
  ('partial repair probe: final rounding',
   [[[10, 20], [30, 60], [10, 0], [30, 150]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 385),
  ('second regression',
   [[[5, 55], [10, 7], [1, 8], [5, 55], [30, 330]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}],
   504),
  ('normal control 1', [[[5, 28]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 396),
  ('normal control 2', [[[5, 25], [30, 60]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 426),
  ('normal control 3', [[[5, 25], [1, 11]], {'flag': 390, 'per_hour': 4150, 'per_km': 230, 'v': 5}], 398),
  ('normal control 4',
   [[[5, 28], [30, 153], [10, 49], [0, 7], [1, 5], [1, 5]],
    {'flag': 300, 'per_hour': 3600, 'per_km': 199, 'v': 5}],
   349)],
 [('regression: final rounding', [[[1, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 245, 'v': 5}], 302),
  ('partial repair probe: final rounding',
   [[[30, 149]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 423),
  ('second regression',
   [[[1, 5], [30, 0], [30, 149], [10, 53]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 467),
  ('normal control 1', [[[1, 11], [0, 3]], {'flag': 390, 'per_hour': 4150, 'per_km': 245, 'v': 5}], 393),
  ('normal control 2',
   [[[1, 7], [30, 153], [10, 110], [10, 53], [1, 5]], {'flag': 300, 'per_hour': 3600, 'per_km': 245, 'v': 5}],
   380),
  ('normal control 3', [[[1, 2], [5, 24]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}], 306),
  ('normal control 4',
   [[[10, 49], [5, 24], [10, 7], [10, 7], [5, 7]], {'flag': 300, 'per_hour': 4150, 'per_km': 230, 'v': 5}],
   346)],
 [('regression: final rounding', [[[10, 50]], {'flag': 300, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 312),
  ('partial repair probe: final rounding',
   [[[5, 25], [5, 25], [1, 0], [10, 7], [0, 0]], {'flag': 300, 'per_hour': 3600, 'per_km': 230, 'v': 5}],
   323),
  ('second regression', [[[1, 5], [10, 7]], {'flag': 300, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 312),
  ('normal control 1', [[[30, 150], [10, 49]], {'flag': 390, 'per_hour': 3900, 'per_km': 230, 'v': 5}], 435),
  ('normal control 2', [[[10, 50], [0, 7], [5, 10]], {'flag': 390, 'per_hour': 4150, 'per_km': 199, 'v': 5}],
   407),
  ('normal control 3', [[[30, 7]], {'flag': 390, 'per_hour': 3600, 'per_km': 245, 'v': 5}], 420),
  ('normal control 4', [[[0, 7]], {'flag': 390, 'per_hour': 3900, 'per_km': 199, 'v': 5}], 391)]]
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: final rounding408408Passed
partial repair probe: final rounding332333Failed
second regression464464Passed
normal control 1380380Passed
normal control 2300300Passed
normal control 3396396Passed
normal control 4460460Passed

SHA-256 / 6a6304e6ffe6a06e4edec35a453182ea7502ac7d9d28d972f50508dbab80b27c

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 2f751968a0f2e21f2c39769107d86a8b6437ca7400aea518ec002604e9d8d8bf