FAILURE MAP
← Case archive

FA-68751 / Toll and parking fee computation / Open access

Open-road gantry trip building: reads are sorted by gantry · case 01

Open-road gantry trip building returns a wrong result when reads are sorted by gantry.

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

ROOT CAUSE

Late-arriving reads are processed out of time order, splitting and duplicating trips.

VERIFIED REPAIR

Restore the read ordering rule so that the step reads `reads = sorted(x['reads'])`.

Unsuccessful approach: Sorting by gantry number ignores time.

Case contract

Input {reads: [[minute, gantry, direction]] unordered, dedupe, max_gap, price per gantry, trip_cap}. Reads are sorted; a read of the same gantry within dedupe minutes (inclusive) of the last kept read of that gantry is dropped. Kept reads join the current trip when the direction matches and the gap from the trip's latest read is <= max_gap, else start a new trip. Each trip pays min(trip_cap, sum of its gantry prices). Return [trips, total].

Why this case matters

Fee engines bill customers in integer cents; a wrong boundary, rounding stage or cap scope silently over- or under-charges.

1 / The failure

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

N = 1
observations = []
def solve(x):
    reads = x['reads']
    kept = []
    lastg = {}
    for t, g, d in reads:
        if g in lastg and t - lastg[g] <= x['dedupe']:
            continue
        lastg[g] = t
        kept.append((t, g, d))
    trips = []
    for t, g, d in kept:
        if trips and trips[-1]['d'] == d and t - trips[-1]['t'] <= x['max_gap']:
            trips[-1]['g'].append(g)
            trips[-1]['t'] = t
        else:
            trips.append({'d': d, 't': t, 'g': [g]})
    total = sum(min(x['trip_cap'], sum(x['price'][g] for g in tr['g'])) for tr in trips)
    return [len(trips), total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'reads': [[68, 4, 'S'], [66, 4, 'S'], [25, 2, 'S'], [35, 0, 'S'], [67, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 900}, [2, 500]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[33, 2, 'S'], [34, 2, 'S'], [36, 5, 'N'], [41, 0, 'S'], [44, 5, 'S'], [46, 5, 'S'], [64, 3, 'S'], [65, 2, 'S'], [68, 4, 'S'], [69, 5, 'S'], [69, 5, 'S'], [79, 1, 'S'], [82, 1, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [75, 200, 200, 75, 150, 110], 'trip_cap': 400}, [3, 710]), ({'reads': [[33, 0, 'S'], [63, 3, 'S'], [94, 1, 'S'], [97, 2, 'S'], [99, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [150, 75, 110, 200, 200, 75], 'trip_cap': 400}, [2, 535]), ({'reads': [[106, 5, 'S'], [75, 1, 'S'], [76, 1, 'S'], [151, 1, 'S'], [107, 5, 'S'], [35, 2, 'S'], [65, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [110, 75, 110, 150, 75, 150], 'trip_cap': 600}, [4, 520]), ({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[1, 1, 'S'], [3, 1, 'S'], [46, 2, 'N'], [56, 1, 'S'], [76, 2, 'S'], [106, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 110, 200], 'trip_cap': 600}, [3, 640]), ({'reads': [[5, 3, 'N'], [35, 5, 'N'], [55, 2, 'N'], [86, 5, 'N'], [116, 2, 'N'], [147, 1, 'N'], [152, 1, 'N'], [153, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 75, 200], 'trip_cap': 400}, [3, 930])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[42, 2, 'N'], [44, 2, 'N'], [87, 2, 'N'], [107, 0, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 200, 75, 110, 150], 'trip_cap': 400}, [2, 510]), ({'reads': [[9, 1, 'S'], [40, 0, 'S'], [60, 0, 'N'], [80, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [150, 200, 200, 200, 150, 150], 'trip_cap': 400}, [3, 700]), ({'reads': [[45, 5, 'S'], [46, 5, 'S'], [48, 2, 'S'], [53, 3, 'S'], [56, 3, 'S'], [84, 2, 'S'], [87, 2, 'S'], [115, 1, 'S'], [146, 2, 'S'], [177, 5, 'S'], [180, 5, 'S'], [182, 0, 'S'], [185, 0, 'S'], [213, 1, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [200, 200, 75, 75, 200, 200], 'trip_cap': 900}, [6, 1300]), ({'reads': [[9, 4, 'S'], [12, 4, 'S'], [17, 4, 'S'], [18, 4, 'S'], [20, 5, 'S'], [30, 5, 'N'], [33, 5, 'N'], [31, 2, 'S'], [31, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 75, 200, 150, 75, 200], 'trip_cap': 400}, [4, 1000]), ({'reads': [[68, 5, 'N'], [8, 1, 'N'], [98, 0, 'N'], [63, 5, 'N'], [8, 1, 'N'], [33, 4, 'N'], [13, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 200, 75, 75, 200, 110], 'trip_cap': 900}, [3, 840]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 3, 'N'], [14, 0, 'N'], [44, 0, 'N'], [89, 5, 'N'], [99, 4, 'N'], [99, 4, 'N'], [130, 4, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 110, 150, 200, 150, 75], 'trip_cap': 400}, [3, 775])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[41, 2, 'S'], [46, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 600}, [1, 350]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[21, 4, 'S'], [83, 1, 'S'], [52, 5, 'S'], [83, 1, 'S'], [84, 4, 'N'], [22, 4, 'S'], [84, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [150, 75, 150, 150, 150, 200], 'trip_cap': 400}, [4, 575]), ({'reads': [[63, 0, 'S'], [35, 0, 'N'], [43, 1, 'N'], [70, 3, 'S'], [65, 0, 'S'], [114, 2, 'S'], [69, 3, 'N'], [43, 0, 'S'], [40, 1, 'N'], [134, 0, 'S'], [72, 3, 'N'], [114, 2, 'S'], [68, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [75, 75, 150, 110, 150, 150], 'trip_cap': 400}, [4, 745]), ({'reads': [[21, 0, 'S'], [31, 3, 'N'], [31, 3, 'N'], [36, 4, 'N'], [81, 5, 'N'], [91, 0, 'N'], [96, 3, 'S'], [99, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 110, 200, 200, 75, 75], 'trip_cap': 400}, [4, 900]), ({'reads': [[15, 5, 'S'], [15, 5, 'S'], [18, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 150, 75, 150, 200], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 0, 'S'], [9, 0, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 150, 150, 75, 110], 'trip_cap': 900}, [1, 110])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[11, 5, 'S'], [56, 0, 'S'], [101, 4, 'N'], [132, 2, 'N'], [133, 5, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 200, 75, 150, 75], 'trip_cap': 600}, [4, 650]), ({'reads': [[5, 2, 'N'], [36, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 110, 150, 110, 200], 'trip_cap': 900}, [2, 220]), ({'reads': [[107, 3, 'N'], [46, 3, 'S'], [157, 3, 'S'], [49, 3, 'S'], [160, 2, 'S'], [140, 2, 'S'], [77, 3, 'N'], [137, 2, 'S'], [36, 5, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 900}, [4, 1530]), ({'reads': [[53, 0, 'N'], [180, 1, 'N'], [130, 1, 'N'], [52, 1, 'N'], [127, 1, 'N'], [50, 1, 'N'], [150, 3, 'N'], [211, 4, 'N'], [51, 0, 'N'], [82, 1, 'N'], [213, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 600}, [5, 1425]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[15, 2, 'N'], [16, 5, 'N'], [21, 5, 'N'], [22, 5, 'S'], [32, 4, 'S'], [52, 3, 'S'], [55, 5, 'S'], [85, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 75, 110, 150, 200], 'trip_cap': 400}, [3, 875]), ({'reads': [[6, 0, 'S'], [51, 2, 'S'], [56, 0, 'S'], [59, 0, 'S'], [87, 0, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 200, 75, 200, 200, 200], 'trip_cap': 900}, [2, 515])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[28, 2, 'S'], [48, 4, 'S'], [78, 0, 'S'], [79, 0, 'S'], [109, 5, 'N'], [154, 5, 'N'], [185, 2, 'N'], [187, 2, 'N'], [216, 0, 'N'], [219, 0, 'N'], [246, 4, 'N'], [291, 5, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 200, 200, 110], 'trip_cap': 900}, [6, 1250]), ({'reads': [[57, 4, 'S'], [58, 4, 'S'], [110, 2, 'N'], [29, 5, 'S'], [80, 0, 'N'], [16, 0, 'N'], [6, 5, 'N'], [77, 0, 'S'], [18, 0, 'N'], [26, 5, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 110, 200, 150, 150], 'trip_cap': 600}, [4, 780]), ({'reads': [[50, 1, 'N'], [50, 1, 'N'], [116, 2, 'N'], [80, 5, 'N'], [111, 3, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 200, 75, 200, 110], 'trip_cap': 600}, [2, 460]), ({'reads': [[65, 3, 'N'], [46, 2, 'N'], [45, 2, 'N'], [95, 4, 'S'], [115, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 110, 110, 110], 'trip_cap': 600}, [2, 480]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[2, 2, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 150, 200, 75, 200], 'trip_cap': 600}, [1, 150]), ({'reads': [[32, 0, 'S'], [35, 0, 'S'], [52, 3, 'S'], [57, 0, 'N'], [77, 3, 'S'], [82, 5, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 75, 75, 110, 110], 'trip_cap': 900}, [3, 480])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 0[1, 500][2, 500]Failed
fee oracle 1[3, 350][2, 350]Failed
fee oracle 2[3, 710][3, 710]Passed
fee oracle 3[2, 535][2, 535]Passed
fee oracle 4[3, 520][4, 520]Failed
fee oracle 5[1, 750][1, 750]Passed
fee oracle 6[3, 640][3, 640]Passed
fee oracle 7[3, 930][3, 930]Passed

SHA-256 / 883484d29ea46af9462082430bee15df2ecb49cce79e8d55872185bcb6fe64aa

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    reads = sorted(x['reads'], key=lambda r: r[1])
    kept = []
    lastg = {}
    for t, g, d in reads:
        if g in lastg and t - lastg[g] <= x['dedupe']:
            continue
        lastg[g] = t
        kept.append((t, g, d))
    trips = []
    for t, g, d in kept:
        if trips and trips[-1]['d'] == d and t - trips[-1]['t'] <= x['max_gap']:
            trips[-1]['g'].append(g)
            trips[-1]['t'] = t
        else:
            trips.append({'d': d, 't': t, 'g': [g]})
    total = sum(min(x['trip_cap'], sum(x['price'][g] for g in tr['g'])) for tr in trips)
    return [len(trips), total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'reads': [[68, 4, 'S'], [66, 4, 'S'], [25, 2, 'S'], [35, 0, 'S'], [67, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 900}, [2, 500]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[33, 2, 'S'], [34, 2, 'S'], [36, 5, 'N'], [41, 0, 'S'], [44, 5, 'S'], [46, 5, 'S'], [64, 3, 'S'], [65, 2, 'S'], [68, 4, 'S'], [69, 5, 'S'], [69, 5, 'S'], [79, 1, 'S'], [82, 1, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [75, 200, 200, 75, 150, 110], 'trip_cap': 400}, [3, 710]), ({'reads': [[33, 0, 'S'], [63, 3, 'S'], [94, 1, 'S'], [97, 2, 'S'], [99, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [150, 75, 110, 200, 200, 75], 'trip_cap': 400}, [2, 535]), ({'reads': [[106, 5, 'S'], [75, 1, 'S'], [76, 1, 'S'], [151, 1, 'S'], [107, 5, 'S'], [35, 2, 'S'], [65, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [110, 75, 110, 150, 75, 150], 'trip_cap': 600}, [4, 520]), ({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[1, 1, 'S'], [3, 1, 'S'], [46, 2, 'N'], [56, 1, 'S'], [76, 2, 'S'], [106, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 110, 200], 'trip_cap': 600}, [3, 640]), ({'reads': [[5, 3, 'N'], [35, 5, 'N'], [55, 2, 'N'], [86, 5, 'N'], [116, 2, 'N'], [147, 1, 'N'], [152, 1, 'N'], [153, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 75, 200], 'trip_cap': 400}, [3, 930])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[42, 2, 'N'], [44, 2, 'N'], [87, 2, 'N'], [107, 0, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 200, 75, 110, 150], 'trip_cap': 400}, [2, 510]), ({'reads': [[9, 1, 'S'], [40, 0, 'S'], [60, 0, 'N'], [80, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [150, 200, 200, 200, 150, 150], 'trip_cap': 400}, [3, 700]), ({'reads': [[45, 5, 'S'], [46, 5, 'S'], [48, 2, 'S'], [53, 3, 'S'], [56, 3, 'S'], [84, 2, 'S'], [87, 2, 'S'], [115, 1, 'S'], [146, 2, 'S'], [177, 5, 'S'], [180, 5, 'S'], [182, 0, 'S'], [185, 0, 'S'], [213, 1, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [200, 200, 75, 75, 200, 200], 'trip_cap': 900}, [6, 1300]), ({'reads': [[9, 4, 'S'], [12, 4, 'S'], [17, 4, 'S'], [18, 4, 'S'], [20, 5, 'S'], [30, 5, 'N'], [33, 5, 'N'], [31, 2, 'S'], [31, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 75, 200, 150, 75, 200], 'trip_cap': 400}, [4, 1000]), ({'reads': [[68, 5, 'N'], [8, 1, 'N'], [98, 0, 'N'], [63, 5, 'N'], [8, 1, 'N'], [33, 4, 'N'], [13, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 200, 75, 75, 200, 110], 'trip_cap': 900}, [3, 840]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 3, 'N'], [14, 0, 'N'], [44, 0, 'N'], [89, 5, 'N'], [99, 4, 'N'], [99, 4, 'N'], [130, 4, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 110, 150, 200, 150, 75], 'trip_cap': 400}, [3, 775])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[41, 2, 'S'], [46, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 600}, [1, 350]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[21, 4, 'S'], [83, 1, 'S'], [52, 5, 'S'], [83, 1, 'S'], [84, 4, 'N'], [22, 4, 'S'], [84, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [150, 75, 150, 150, 150, 200], 'trip_cap': 400}, [4, 575]), ({'reads': [[63, 0, 'S'], [35, 0, 'N'], [43, 1, 'N'], [70, 3, 'S'], [65, 0, 'S'], [114, 2, 'S'], [69, 3, 'N'], [43, 0, 'S'], [40, 1, 'N'], [134, 0, 'S'], [72, 3, 'N'], [114, 2, 'S'], [68, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [75, 75, 150, 110, 150, 150], 'trip_cap': 400}, [4, 745]), ({'reads': [[21, 0, 'S'], [31, 3, 'N'], [31, 3, 'N'], [36, 4, 'N'], [81, 5, 'N'], [91, 0, 'N'], [96, 3, 'S'], [99, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 110, 200, 200, 75, 75], 'trip_cap': 400}, [4, 900]), ({'reads': [[15, 5, 'S'], [15, 5, 'S'], [18, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 150, 75, 150, 200], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 0, 'S'], [9, 0, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 150, 150, 75, 110], 'trip_cap': 900}, [1, 110])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[11, 5, 'S'], [56, 0, 'S'], [101, 4, 'N'], [132, 2, 'N'], [133, 5, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 200, 75, 150, 75], 'trip_cap': 600}, [4, 650]), ({'reads': [[5, 2, 'N'], [36, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 110, 150, 110, 200], 'trip_cap': 900}, [2, 220]), ({'reads': [[107, 3, 'N'], [46, 3, 'S'], [157, 3, 'S'], [49, 3, 'S'], [160, 2, 'S'], [140, 2, 'S'], [77, 3, 'N'], [137, 2, 'S'], [36, 5, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 900}, [4, 1530]), ({'reads': [[53, 0, 'N'], [180, 1, 'N'], [130, 1, 'N'], [52, 1, 'N'], [127, 1, 'N'], [50, 1, 'N'], [150, 3, 'N'], [211, 4, 'N'], [51, 0, 'N'], [82, 1, 'N'], [213, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 600}, [5, 1425]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[15, 2, 'N'], [16, 5, 'N'], [21, 5, 'N'], [22, 5, 'S'], [32, 4, 'S'], [52, 3, 'S'], [55, 5, 'S'], [85, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 75, 110, 150, 200], 'trip_cap': 400}, [3, 875]), ({'reads': [[6, 0, 'S'], [51, 2, 'S'], [56, 0, 'S'], [59, 0, 'S'], [87, 0, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 200, 75, 200, 200, 200], 'trip_cap': 900}, [2, 515])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[28, 2, 'S'], [48, 4, 'S'], [78, 0, 'S'], [79, 0, 'S'], [109, 5, 'N'], [154, 5, 'N'], [185, 2, 'N'], [187, 2, 'N'], [216, 0, 'N'], [219, 0, 'N'], [246, 4, 'N'], [291, 5, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 200, 200, 110], 'trip_cap': 900}, [6, 1250]), ({'reads': [[57, 4, 'S'], [58, 4, 'S'], [110, 2, 'N'], [29, 5, 'S'], [80, 0, 'N'], [16, 0, 'N'], [6, 5, 'N'], [77, 0, 'S'], [18, 0, 'N'], [26, 5, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 110, 200, 150, 150], 'trip_cap': 600}, [4, 780]), ({'reads': [[50, 1, 'N'], [50, 1, 'N'], [116, 2, 'N'], [80, 5, 'N'], [111, 3, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 200, 75, 200, 110], 'trip_cap': 600}, [2, 460]), ({'reads': [[65, 3, 'N'], [46, 2, 'N'], [45, 2, 'N'], [95, 4, 'S'], [115, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 110, 110, 110], 'trip_cap': 600}, [2, 480]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[2, 2, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 150, 200, 75, 200], 'trip_cap': 600}, [1, 150]), ({'reads': [[32, 0, 'S'], [35, 0, 'S'], [52, 3, 'S'], [57, 0, 'N'], [77, 3, 'S'], [82, 5, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 75, 75, 110, 110], 'trip_cap': 900}, [3, 480])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 0[2, 500][2, 500]Passed
fee oracle 1[2, 350][2, 350]Passed
fee oracle 2[6, 1205][3, 710]Failed
fee oracle 3[2, 535][2, 535]Passed
fee oracle 4[4, 520][4, 520]Passed
fee oracle 5[1, 750][1, 750]Passed
fee oracle 6[4, 640][3, 640]Failed
fee oracle 7[3, 930][3, 930]Passed

SHA-256 / 487298f12cd35b77be8a15b5208e1dc5f3dd2593a4a14e2cb66e27a43c5a3adb

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    reads = sorted(x['reads'])
    kept = []
    lastg = {}
    for t, g, d in reads:
        if g in lastg and t - lastg[g] <= x['dedupe']:
            continue
        lastg[g] = t
        kept.append((t, g, d))
    trips = []
    for t, g, d in kept:
        if trips and trips[-1]['d'] == d and t - trips[-1]['t'] <= x['max_gap']:
            trips[-1]['g'].append(g)
            trips[-1]['t'] = t
        else:
            trips.append({'d': d, 't': t, 'g': [g]})
    total = sum(min(x['trip_cap'], sum(x['price'][g] for g in tr['g'])) for tr in trips)
    return [len(trips), total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'reads': [[68, 4, 'S'], [66, 4, 'S'], [25, 2, 'S'], [35, 0, 'S'], [67, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 900}, [2, 500]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[33, 2, 'S'], [34, 2, 'S'], [36, 5, 'N'], [41, 0, 'S'], [44, 5, 'S'], [46, 5, 'S'], [64, 3, 'S'], [65, 2, 'S'], [68, 4, 'S'], [69, 5, 'S'], [69, 5, 'S'], [79, 1, 'S'], [82, 1, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [75, 200, 200, 75, 150, 110], 'trip_cap': 400}, [3, 710]), ({'reads': [[33, 0, 'S'], [63, 3, 'S'], [94, 1, 'S'], [97, 2, 'S'], [99, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [150, 75, 110, 200, 200, 75], 'trip_cap': 400}, [2, 535]), ({'reads': [[106, 5, 'S'], [75, 1, 'S'], [76, 1, 'S'], [151, 1, 'S'], [107, 5, 'S'], [35, 2, 'S'], [65, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [110, 75, 110, 150, 75, 150], 'trip_cap': 600}, [4, 520]), ({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[1, 1, 'S'], [3, 1, 'S'], [46, 2, 'N'], [56, 1, 'S'], [76, 2, 'S'], [106, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 110, 200], 'trip_cap': 600}, [3, 640]), ({'reads': [[5, 3, 'N'], [35, 5, 'N'], [55, 2, 'N'], [86, 5, 'N'], [116, 2, 'N'], [147, 1, 'N'], [152, 1, 'N'], [153, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 110, 200, 75, 200], 'trip_cap': 400}, [3, 930])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[42, 2, 'N'], [44, 2, 'N'], [87, 2, 'N'], [107, 0, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 200, 75, 110, 150], 'trip_cap': 400}, [2, 510]), ({'reads': [[9, 1, 'S'], [40, 0, 'S'], [60, 0, 'N'], [80, 1, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [150, 200, 200, 200, 150, 150], 'trip_cap': 400}, [3, 700]), ({'reads': [[45, 5, 'S'], [46, 5, 'S'], [48, 2, 'S'], [53, 3, 'S'], [56, 3, 'S'], [84, 2, 'S'], [87, 2, 'S'], [115, 1, 'S'], [146, 2, 'S'], [177, 5, 'S'], [180, 5, 'S'], [182, 0, 'S'], [185, 0, 'S'], [213, 1, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [200, 200, 75, 75, 200, 200], 'trip_cap': 900}, [6, 1300]), ({'reads': [[9, 4, 'S'], [12, 4, 'S'], [17, 4, 'S'], [18, 4, 'S'], [20, 5, 'S'], [30, 5, 'N'], [33, 5, 'N'], [31, 2, 'S'], [31, 2, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 75, 200, 150, 75, 200], 'trip_cap': 400}, [4, 1000]), ({'reads': [[68, 5, 'N'], [8, 1, 'N'], [98, 0, 'N'], [63, 5, 'N'], [8, 1, 'N'], [33, 4, 'N'], [13, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 200, 75, 75, 200, 110], 'trip_cap': 900}, [3, 840]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 3, 'N'], [14, 0, 'N'], [44, 0, 'N'], [89, 5, 'N'], [99, 4, 'N'], [99, 4, 'N'], [130, 4, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 110, 150, 200, 150, 75], 'trip_cap': 400}, [3, 775])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[41, 2, 'S'], [46, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [200, 200, 150, 200, 150, 110], 'trip_cap': 600}, [1, 350]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[21, 4, 'S'], [83, 1, 'S'], [52, 5, 'S'], [83, 1, 'S'], [84, 4, 'N'], [22, 4, 'S'], [84, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [150, 75, 150, 150, 150, 200], 'trip_cap': 400}, [4, 575]), ({'reads': [[63, 0, 'S'], [35, 0, 'N'], [43, 1, 'N'], [70, 3, 'S'], [65, 0, 'S'], [114, 2, 'S'], [69, 3, 'N'], [43, 0, 'S'], [40, 1, 'N'], [134, 0, 'S'], [72, 3, 'N'], [114, 2, 'S'], [68, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [75, 75, 150, 110, 150, 150], 'trip_cap': 400}, [4, 745]), ({'reads': [[21, 0, 'S'], [31, 3, 'N'], [31, 3, 'N'], [36, 4, 'N'], [81, 5, 'N'], [91, 0, 'N'], [96, 3, 'S'], [99, 3, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 110, 200, 200, 75, 75], 'trip_cap': 400}, [4, 900]), ({'reads': [[15, 5, 'S'], [15, 5, 'S'], [18, 0, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 150, 75, 150, 200], 'trip_cap': 400}, [2, 350]), ({'reads': [[11, 0, 'S'], [9, 0, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 110, 150, 150, 75, 110], 'trip_cap': 900}, [1, 110])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[11, 5, 'S'], [56, 0, 'S'], [101, 4, 'N'], [132, 2, 'N'], [133, 5, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [150, 150, 200, 75, 150, 75], 'trip_cap': 600}, [4, 650]), ({'reads': [[5, 2, 'N'], [36, 4, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [200, 200, 110, 150, 110, 200], 'trip_cap': 900}, [2, 220]), ({'reads': [[107, 3, 'N'], [46, 3, 'S'], [157, 3, 'S'], [49, 3, 'S'], [160, 2, 'S'], [140, 2, 'S'], [77, 3, 'N'], [137, 2, 'S'], [36, 5, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 900}, [4, 1530]), ({'reads': [[53, 0, 'N'], [180, 1, 'N'], [130, 1, 'N'], [52, 1, 'N'], [127, 1, 'N'], [50, 1, 'N'], [150, 3, 'N'], [211, 4, 'N'], [51, 0, 'N'], [82, 1, 'N'], [213, 4, 'N']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 110, 200, 150, 200], 'trip_cap': 600}, [5, 1425]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[15, 2, 'N'], [16, 5, 'N'], [21, 5, 'N'], [22, 5, 'S'], [32, 4, 'S'], [52, 3, 'S'], [55, 5, 'S'], [85, 2, 'S']], 'dedupe': 2, 'max_gap': 20, 'price': [75, 200, 75, 110, 150, 200], 'trip_cap': 400}, [3, 875]), ({'reads': [[6, 0, 'S'], [51, 2, 'S'], [56, 0, 'S'], [59, 0, 'S'], [87, 0, 'S']], 'dedupe': 2, 'max_gap': 30, 'price': [110, 200, 75, 200, 200, 200], 'trip_cap': 900}, [2, 515])], [({'reads': [[0, 1, 'N'], [2, 1, 'N'], [4, 1, 'N'], [30, 2, 'N'], [55, 3, 'N']], 'dedupe': 2, 'max_gap': 30, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 900}, [1, 750]), ({'reads': [[28, 2, 'S'], [48, 4, 'S'], [78, 0, 'S'], [79, 0, 'S'], [109, 5, 'N'], [154, 5, 'N'], [185, 2, 'N'], [187, 2, 'N'], [216, 0, 'N'], [219, 0, 'N'], [246, 4, 'N'], [291, 5, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 200, 200, 110], 'trip_cap': 900}, [6, 1250]), ({'reads': [[57, 4, 'S'], [58, 4, 'S'], [110, 2, 'N'], [29, 5, 'S'], [80, 0, 'N'], [16, 0, 'N'], [6, 5, 'N'], [77, 0, 'S'], [18, 0, 'N'], [26, 5, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 110, 200, 150, 150], 'trip_cap': 600}, [4, 780]), ({'reads': [[50, 1, 'N'], [50, 1, 'N'], [116, 2, 'N'], [80, 5, 'N'], [111, 3, 'N']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 200, 75, 200, 110], 'trip_cap': 600}, [2, 460]), ({'reads': [[65, 3, 'N'], [46, 2, 'N'], [45, 2, 'N'], [95, 4, 'S'], [115, 3, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 200, 150, 110, 110, 110], 'trip_cap': 600}, [2, 480]), ({'reads': [[10, 0, 'S'], [5, 4, 'N'], [12, 1, 'S'], [11, 0, 'S']], 'dedupe': 3, 'max_gap': 20, 'price': [100, 150, 200, 250, 100, 100], 'trip_cap': 400}, [2, 350]), ({'reads': [[2, 2, 'N']], 'dedupe': 3, 'max_gap': 20, 'price': [110, 75, 150, 200, 75, 200], 'trip_cap': 600}, [1, 150]), ({'reads': [[32, 0, 'S'], [35, 0, 'S'], [52, 3, 'S'], [57, 0, 'N'], [77, 3, 'S'], [82, 5, 'S']], 'dedupe': 3, 'max_gap': 30, 'price': [110, 75, 75, 75, 110, 110], 'trip_cap': 900}, [3, 480])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('fee oracle' + ' %d' % i, 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
fee oracle 0[2, 500][2, 500]Passed
fee oracle 1[2, 350][2, 350]Passed
fee oracle 2[3, 710][3, 710]Passed
fee oracle 3[2, 535][2, 535]Passed
fee oracle 4[4, 520][4, 520]Passed
fee oracle 5[1, 750][1, 750]Passed
fee oracle 6[3, 640][3, 640]Passed
fee oracle 7[3, 930][3, 930]Passed

SHA-256 / 74603f61455c3eea406a464630660515306dc20828e1f5f35fb5e3c6c6d030b3

Verification & scope

A deterministic, bounded toy model with a stipulated contract; it makes no claim of conformance to any agency manual or standard. 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:48:05.143066+00:00.

Case digest / 3e415e971353729a1335e15634f9e9fb652bf81b1f2a550a152af9d4023c6105