FAILURE MAP
← Case archive

FA-66356 / Airline fare rule evaluation / Open access

Ticketing time limit hours interpreted as days · case 01

A 24-hour ticketing limit allows tickets issued three weeks after booking.

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

ROOT CAUSE

The ticket_within_h value is passed to timedelta as days.

VERIFIED REPAIR

Build the time limit with hours.

Unsuccessful approach: Adding a grace day keeps the units right but extends every time limit.

Case contract

Input {'res','ticket','depart' ISO local datetimes,'ap_days','ticket_within_h'}. Ticket before reservation -> 'ERR_ORDER'. AP counts calendar days between the ticketing date and the departure date (>= ap_days passes) and is checked before the ticketing time limit; ticketing must be at or before reservation + ticket_within_h hours. Return 'PASS', 'FAIL_AP' or 'FAIL_TKT_TL'.

Why this case matters

Advance purchase rules count calendar days, not elapsed 24-hour periods, and interact with a separate ticketing time limit after booking.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    T = datetime.datetime.fromisoformat(x['ticket'])
    D = datetime.datetime.fromisoformat(x['depart'])
    R = datetime.datetime.fromisoformat(x['res'])
    if T < R: return 'ERR_ORDER'
    if (D.date() - T.date()).days < x['ap_days']: return 'FAIL_AP'
    if T > R + datetime.timedelta(days=x['ticket_within_h']): return 'FAIL_TKT_TL'
    return 'PASS'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['regression: ticketing time limit units', {'res': '2028-05-16T08:00', 'ticket': '2028-05-18T08:00', 'depart': '2028-05-31T18:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['regression: ticketing time limit units', {'res': '2028-01-11T06:00', 'ticket': '2028-01-14T06:00', 'depart': '2028-02-03T14:00', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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
late evening ticket, early departurePASSPASSPassed
exactly AP daysPASSPASSPassed
one day shortFAIL_APFAIL_APPassed
ticketed at exact time limitPASSPASSPassed
ticketed after time limitPASSFAIL_TKT_TLFailed
ticket before reservationERR_ORDERERR_ORDERPassed
AP and time limit both failFAIL_APFAIL_APPassed
sampled case 1FAIL_APFAIL_APPassed
sampled case 2PASSPASSPassed
sampled case 3FAIL_APFAIL_APPassed
regression: ticketing time limit unitsPASSFAIL_TKT_TLFailed

SHA-256 / dd7df47d65249f767aeccacb8a13796e89896bdf6a472a255bf7134ee2e4c4c9

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    T = datetime.datetime.fromisoformat(x['ticket'])
    D = datetime.datetime.fromisoformat(x['depart'])
    R = datetime.datetime.fromisoformat(x['res'])
    if T < R: return 'ERR_ORDER'
    if (D.date() - T.date()).days < x['ap_days']: return 'FAIL_AP'
    if T > R + datetime.timedelta(hours=x['ticket_within_h'] + 24): return 'FAIL_TKT_TL'
    return 'PASS'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['regression: ticketing time limit units', {'res': '2028-05-16T08:00', 'ticket': '2028-05-18T08:00', 'depart': '2028-05-31T18:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['regression: ticketing time limit units', {'res': '2028-01-11T06:00', 'ticket': '2028-01-14T06:00', 'depart': '2028-02-03T14:00', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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
late evening ticket, early departurePASSPASSPassed
exactly AP daysPASSPASSPassed
one day shortFAIL_APFAIL_APPassed
ticketed at exact time limitPASSPASSPassed
ticketed after time limitFAIL_TKT_TLFAIL_TKT_TLPassed
ticket before reservationERR_ORDERERR_ORDERPassed
AP and time limit both failFAIL_APFAIL_APPassed
sampled case 1FAIL_APFAIL_APPassed
sampled case 2PASSPASSPassed
sampled case 3FAIL_APFAIL_APPassed
regression: ticketing time limit unitsPASSFAIL_TKT_TLFailed

SHA-256 / 11183728a94b4fc77be8543d2eee44f1975eb17af9dbeacf3d18748eb381273c

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    T = datetime.datetime.fromisoformat(x['ticket'])
    D = datetime.datetime.fromisoformat(x['depart'])
    R = datetime.datetime.fromisoformat(x['res'])
    if T < R: return 'ERR_ORDER'
    if (D.date() - T.date()).days < x['ap_days']: return 'FAIL_AP'
    if T > R + datetime.timedelta(hours=x['ticket_within_h']): return 'FAIL_TKT_TL'
    return 'PASS'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-15T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 25}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:05', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:51', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-23T19:45', 'ticket': '2029-04-25T19:45', 'depart': '2029-05-10T07:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-12-29T20:45', 'ticket': '2028-12-30T21:15', 'depart': '2029-01-24T15:15', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['sampled case 3', {'res': '2029-11-28T18:15', 'ticket': '2029-11-29T14:45', 'depart': '2029-12-08T20:45', 'ap_days': 21, 'ticket_within_h': 72}, 'FAIL_AP'], ['regression: ticketing time limit units', {'res': '2028-05-16T08:00', 'ticket': '2028-05-18T08:00', 'depart': '2028-05-31T18:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-16T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 26}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:10', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:52', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-03-02T18:30', 'ticket': '2029-03-05T19:00', 'depart': '2029-03-14T02:00', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 2', {'res': '2028-11-19T00:15', 'ticket': '2028-11-20T00:15', 'depart': '2028-12-13T04:15', 'ap_days': 7, 'ticket_within_h': 24}, 'PASS'], ['sampled case 3', {'res': '2028-08-13T05:15', 'ticket': '2028-08-13T20:45', 'depart': '2028-08-18T10:45', 'ap_days': 3, 'ticket_within_h': 72}, 'PASS'], ['regression: ticketing time limit units', {'res': '2028-01-11T06:00', 'ticket': '2028-01-14T06:00', 'depart': '2028-02-03T14:00', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-17T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 27}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:15', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:53', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 72}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-01-07T10:45', 'ticket': '2028-01-10T11:15', 'depart': '2028-01-27T06:15', 'ap_days': 14, 'ticket_within_h': 72}, 'FAIL_TKT_TL'], ['sampled case 2', {'res': '2027-11-20T22:00', 'ticket': '2027-11-23T02:00', 'depart': '2027-12-12T09:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['sampled case 3', {'res': '2029-01-16T10:15', 'ticket': '2029-01-17T10:45', 'depart': '2029-02-13T03:45', 'ap_days': 14, 'ticket_within_h': 24}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-18T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 28}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:20', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:54', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 96}, 'FAIL_AP'], ['sampled case 1', {'res': '2028-04-10T05:15', 'ticket': '2028-04-13T05:15', 'depart': '2028-04-21T10:15', 'ap_days': 14, 'ticket_within_h': 48}, 'FAIL_AP'], ['sampled case 2', {'res': '2029-06-06T12:45', 'ticket': '2029-06-09T12:45', 'depart': '2029-07-06T08:45', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-10-21T12:00', 'ticket': '2029-10-24T12:00', 'depart': '2029-11-15T19:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_TKT_TL']], [['late evening ticket, early departure', {'res': '2027-03-01T09:00', 'ticket': '2027-03-01T22:30', 'depart': '2027-03-19T06:00', 'ap_days': 14, 'ticket_within_h': 24}, 'PASS'], ['exactly AP days', {'res': '2027-05-10T10:00', 'ticket': '2027-05-10T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 29}, 'PASS'], ['one day short', {'res': '2027-05-10T10:00', 'ticket': '2027-05-11T11:00', 'depart': '2027-05-17T08:00', 'ap_days': 7, 'ticket_within_h': 48}, 'FAIL_AP'], ['ticketed at exact time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-02T08:00', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'PASS'], ['ticketed after time limit', {'res': '2027-06-01T08:00', 'ticket': '2027-06-03T09:25', 'depart': '2027-07-01T08:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_TKT_TL'], ['ticket before reservation', {'res': '2027-06-01T08:00', 'ticket': '2027-06-01T07:55', 'depart': '2027-07-01T08:00', 'ap_days': 3, 'ticket_within_h': 24}, 'ERR_ORDER'], ['AP and time limit both fail', {'res': '2027-08-01T08:00', 'ticket': '2027-08-05T08:00', 'depart': '2027-08-08T08:00', 'ap_days': 7, 'ticket_within_h': 120}, 'FAIL_AP'], ['sampled case 1', {'res': '2029-04-07T13:45', 'ticket': '2029-04-08T19:15', 'depart': '2029-04-19T08:15', 'ap_days': 3, 'ticket_within_h': 48}, 'PASS'], ['sampled case 2', {'res': '2027-04-03T07:45', 'ticket': '2027-04-05T08:15', 'depart': '2027-05-01T01:15', 'ap_days': 3, 'ticket_within_h': 48}, 'FAIL_TKT_TL'], ['sampled case 3', {'res': '2029-01-24T00:30', 'ticket': '2029-01-25T01:00', 'depart': '2029-02-11T22:00', 'ap_days': 7, 'ticket_within_h': 24}, 'FAIL_TKT_TL']]]
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
late evening ticket, early departurePASSPASSPassed
exactly AP daysPASSPASSPassed
one day shortFAIL_APFAIL_APPassed
ticketed at exact time limitPASSPASSPassed
ticketed after time limitFAIL_TKT_TLFAIL_TKT_TLPassed
ticket before reservationERR_ORDERERR_ORDERPassed
AP and time limit both failFAIL_APFAIL_APPassed
sampled case 1FAIL_APFAIL_APPassed
sampled case 2PASSPASSPassed
sampled case 3FAIL_APFAIL_APPassed
regression: ticketing time limit unitsFAIL_TKT_TLFAIL_TKT_TLPassed

SHA-256 / 1badd342a561f43603672287e92831dbd241cd4ecbda240d10ac8f0d13f3d0e0

Verification & scope

A stipulated toy fare-rule contract with invented constants; it is not an ATPCO or carrier tariff implementation and makes no claim of industry-standard conformance. 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:47:42.708821+00:00.

Case digest / edb79b2dd66c18e9c416e892325527d00167f5bd2a05b086a4cce0a9ab656c73