FAILURE MAP
← Case archive

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

Time-band rate with calendar day cap: the last segment runs to the band boundary · case 01

Time-band rate with calendar day cap returns a wrong result when the last segment runs to the band boundary.

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

ROOT CAUSE

The final segment is not clipped at the exit time, charging until the end of the band.

THE FAILURE

The final segment is not clipped at the exit time, charging until the end of the band.

Unsuccessful approach: Counting the exit minute inclusively adds one minute to every stay.

Case contract

Input {bands: [[start minute of day, cents per quarter hour]] sorted with first start 0, entry, exit (absolute minutes), daily_max}. Minutes of the stay are totalled per calendar day and band; each total is rounded up to whole quarter hours and priced at its band rate. Each calendar day's charge is capped at daily_max.

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):
    bands = x['bands']
    per = {}
    t = x['entry']
    while t < x['exit']:
        day, tod = divmod(t, 1440)
        i = max(k for k in range(len(bands)) if bands[k][0] <= tod)
        nxt = bands[i + 1][0] if i + 1 < len(bands) else 1440
        step = nxt - tod
        key = (day, bands[i][1])
        per[key] = per.get(key, 0) + step
        t += step
    days = {}
    for (day, rate), m in per.items():
        days[day] = days.get(day, 0) + -(-m // 15) * rate
    return sum(min(v, x['daily_max']) for v in days.values())
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'bands': [[0, 25], [270, 100], [990, 50]], 'entry': 868, 'exit': 1042, 'daily_max': 4000}, 1100), ({'bands': [[0, 50], [240, 100]], 'entry': 589, 'exit': 1071, 'daily_max': 2500}, 2500), ({'bands': [[0, 50], [240, 100], [270, 50], [1290, 100]], 'entry': 917, 'exit': 3111, 'daily_max': 4000}, 7050), ({'bands': [[0, 25], [720, 50], [1170, 50]], 'entry': 1295, 'exit': 3926, 'daily_max': 1500}, 3500), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 25], [540, 50], [570, 50], [750, 50]], 'entry': 839, 'exit': 955, 'daily_max': 4000}, 400), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)], [({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [420, 25], [870, 50]], 'entry': 1876, 'exit': 2012, 'daily_max': 4000}, 250), ({'bands': [[0, 50], [240, 25]], 'entry': 1263, 'exit': 2110, 'daily_max': 1500}, 1800), ({'bands': [[0, 25], [90, 100]], 'entry': 1185, 'exit': 1824, 'daily_max': 4000}, 3850), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [1050, 100], [1110, 100]], 'entry': 1397, 'exit': 4275, 'daily_max': 4000}, 8300), ({'bands': [[0, 50], [630, 25], [870, 50], [1020, 25]], 'entry': 1314, 'exit': 2055, 'daily_max': 1500}, 1725), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)], [({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [90, 50], [1080, 25]], 'entry': 162, 'exit': 368, 'daily_max': 1500}, 700), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000), ({'bands': [[0, 50], [180, 100], [330, 100]], 'entry': 1920, 'exit': 4850, 'daily_max': 1500}, 4500), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 50], [90, 100], [900, 50]], 'entry': 462, 'exit': 2519, 'daily_max': 2500}, 5000), ({'bands': [[0, 50], [570, 100], [630, 100], [1020, 25]], 'entry': 1999, 'exit': 2569, 'daily_max': 4000}, 3250), ({'bands': [[0, 25], [390, 100], [540, 25], [720, 100]], 'entry': 440, 'exit': 1260, 'daily_max': 2500}, 2500)], [({'bands': [[0, 50], [90, 50], [1110, 100]], 'entry': 314, 'exit': 1024, 'daily_max': 1500}, 1500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000), ({'bands': [[0, 50], [120, 50], [810, 50], [1260, 50]], 'entry': 224, 'exit': 385, 'daily_max': 2500}, 550), ({'bands': [[0, 50], [210, 100]], 'entry': 1190, 'exit': 3970, 'daily_max': 2500}, 6700), ({'bands': [[0, 50], [60, 50], [150, 100], [240, 100]], 'entry': 1440, 'exit': 1620, 'daily_max': 1500}, 700), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 50], [180, 25], [510, 100], [1200, 50]], 'entry': 352, 'exit': 507, 'daily_max': 1500}, 275)], [({'bands': [[0, 25], [180, 100]], 'entry': 314, 'exit': 666, 'daily_max': 2500}, 2400), ({'bands': [[0, 50], [270, 25], [570, 25]], 'entry': 1749, 'exit': 1907, 'daily_max': 4000}, 275), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [690, 25]], 'entry': 1544, 'exit': 2485, 'daily_max': 2500}, 2500), ({'bands': [[0, 25], [90, 100], [690, 25]], 'entry': 1551, 'exit': 2298, 'daily_max': 2500}, 2500), ({'bands': [[0, 50], [1080, 25], [1170, 100]], 'entry': 785, 'exit': 1295, 'daily_max': 1500}, 1500), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)]]
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 024001100Failed
fee oracle 125002500Passed
fee oracle 270507050Passed
fee oracle 335003500Passed
fee oracle 41800500Failed
fee oracle 551254550Failed
fee oracle 62050400Failed
fee oracle 740004000Passed

SHA-256 / f38d1132b7f4bfc9a467dd637e2b346f884d73b657fe3692287e01a436611ec7

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    bands = x['bands']
    per = {}
    t = x['entry']
    while t < x['exit']:
        day, tod = divmod(t, 1440)
        i = max(k for k in range(len(bands)) if bands[k][0] <= tod)
        nxt = bands[i + 1][0] if i + 1 < len(bands) else 1440
        step = min(x['exit'] - t + 1, nxt - tod)
        key = (day, bands[i][1])
        per[key] = per.get(key, 0) + step
        t += step
    days = {}
    for (day, rate), m in per.items():
        days[day] = days.get(day, 0) + -(-m // 15) * rate
    return sum(min(v, x['daily_max']) for v in days.values())
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'bands': [[0, 25], [270, 100], [990, 50]], 'entry': 868, 'exit': 1042, 'daily_max': 4000}, 1100), ({'bands': [[0, 50], [240, 100]], 'entry': 589, 'exit': 1071, 'daily_max': 2500}, 2500), ({'bands': [[0, 50], [240, 100], [270, 50], [1290, 100]], 'entry': 917, 'exit': 3111, 'daily_max': 4000}, 7050), ({'bands': [[0, 25], [720, 50], [1170, 50]], 'entry': 1295, 'exit': 3926, 'daily_max': 1500}, 3500), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 25], [540, 50], [570, 50], [750, 50]], 'entry': 839, 'exit': 955, 'daily_max': 4000}, 400), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)], [({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [420, 25], [870, 50]], 'entry': 1876, 'exit': 2012, 'daily_max': 4000}, 250), ({'bands': [[0, 50], [240, 25]], 'entry': 1263, 'exit': 2110, 'daily_max': 1500}, 1800), ({'bands': [[0, 25], [90, 100]], 'entry': 1185, 'exit': 1824, 'daily_max': 4000}, 3850), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [1050, 100], [1110, 100]], 'entry': 1397, 'exit': 4275, 'daily_max': 4000}, 8300), ({'bands': [[0, 50], [630, 25], [870, 50], [1020, 25]], 'entry': 1314, 'exit': 2055, 'daily_max': 1500}, 1725), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)], [({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [90, 50], [1080, 25]], 'entry': 162, 'exit': 368, 'daily_max': 1500}, 700), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000), ({'bands': [[0, 50], [180, 100], [330, 100]], 'entry': 1920, 'exit': 4850, 'daily_max': 1500}, 4500), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 50], [90, 100], [900, 50]], 'entry': 462, 'exit': 2519, 'daily_max': 2500}, 5000), ({'bands': [[0, 50], [570, 100], [630, 100], [1020, 25]], 'entry': 1999, 'exit': 2569, 'daily_max': 4000}, 3250), ({'bands': [[0, 25], [390, 100], [540, 25], [720, 100]], 'entry': 440, 'exit': 1260, 'daily_max': 2500}, 2500)], [({'bands': [[0, 50], [90, 50], [1110, 100]], 'entry': 314, 'exit': 1024, 'daily_max': 1500}, 1500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000), ({'bands': [[0, 50], [120, 50], [810, 50], [1260, 50]], 'entry': 224, 'exit': 385, 'daily_max': 2500}, 550), ({'bands': [[0, 50], [210, 100]], 'entry': 1190, 'exit': 3970, 'daily_max': 2500}, 6700), ({'bands': [[0, 50], [60, 50], [150, 100], [240, 100]], 'entry': 1440, 'exit': 1620, 'daily_max': 1500}, 700), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 50], [180, 25], [510, 100], [1200, 50]], 'entry': 352, 'exit': 507, 'daily_max': 1500}, 275)], [({'bands': [[0, 25], [180, 100]], 'entry': 314, 'exit': 666, 'daily_max': 2500}, 2400), ({'bands': [[0, 50], [270, 25], [570, 25]], 'entry': 1749, 'exit': 1907, 'daily_max': 4000}, 275), ({'bands': [[0, 50], [720, 100]], 'entry': 1400, 'exit': 1500, 'daily_max': 1500}, 500), ({'bands': [[0, 25], [420, 100], [1080, 25]], 'entry': 350, 'exit': 1100, 'daily_max': 9000}, 4550), ({'bands': [[0, 50], [690, 25]], 'entry': 1544, 'exit': 2485, 'daily_max': 2500}, 2500), ({'bands': [[0, 25], [90, 100], [690, 25]], 'entry': 1551, 'exit': 2298, 'daily_max': 2500}, 2500), ({'bands': [[0, 50], [1080, 25], [1170, 100]], 'entry': 785, 'exit': 1295, 'daily_max': 1500}, 1500), ({'bands': [[0, 25], [420, 100], [1080, 50]], 'entry': 400, 'exit': 1100, 'daily_max': 4000}, 4000)]]
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 011001100Passed
fee oracle 125002500Passed
fee oracle 270507050Passed
fee oracle 335003500Passed
fee oracle 4550500Failed
fee oracle 545754550Failed
fee oracle 6400400Passed
fee oracle 740004000Passed

SHA-256 / e595d2bbc944866270d0a7f4d0c0fdb10e0088821a4e3be04813c66905bf5df0

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 8 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, 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:02.188103+00:00.

Case digest / ebab38395c8c037fe03f12265ab47b71702034b35685e9c8f0c8170cee42db48