FAILURE MAP
← Case archive

FA-66366 / Airline fare rule evaluation / Open access

Ticketing time limit reported ahead of an advance purchase failure · case 01

A late ticket that also misses advance purchase is reported only as a time-limit failure.

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

ROOT CAUSE

The AP check was moved after the ticketing time limit check.

VERIFIED REPAIR

Evaluate AP immediately after the ordering guard.

Unsuccessful approach: Moving the ordering guard to the end instead lets FAIL_AP mask an out-of-order record.

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 T > R + datetime.timedelta(hours=x['ticket_within_h']): return 'FAIL_TKT_TL'
    if (D.date() - T.date()).days < x['ap_days']: return 'FAIL_AP'
    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: rule evaluation order', {'res': '2027-03-25T22:45', 'ticket': '2027-03-25T21:15', 'depart': '2027-03-25T10:15', 'ap_days': 14, 'ticket_within_h': 24}, 'ERR_ORDER']], [['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: rule evaluation order', {'res': '2029-07-27T13:45', 'ticket': '2029-07-27T11:15', 'depart': '2029-07-29T18:15', 'ap_days': 21, 'ticket_within_h': 72}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2027-02-09T15:45', 'ticket': '2027-02-09T13:15', 'depart': '2027-02-10T04:15', 'ap_days': 3, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2029-02-14T16:30', 'ticket': '2029-02-14T13:30', 'depart': '2029-02-16T10:30', 'ap_days': 7, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2028-12-10T18:30', 'ticket': '2028-12-13T06:00', 'depart': '2028-12-26T10:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['regression: rule evaluation order', {'res': '2028-05-25T16:30', 'ticket': '2028-05-25T14:30', 'depart': '2028-06-02T22:30', 'ap_days': 21, 'ticket_within_h': 24}, 'ERR_ORDER']]]
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_TKT_TLFAIL_APFailed
sampled case 1FAIL_APFAIL_APPassed
sampled case 2PASSPASSPassed
sampled case 3FAIL_APFAIL_APPassed
regression: rule evaluation orderERR_ORDERERR_ORDERPassed

SHA-256 / 20422e283ac2ffffed8fc795b02c2075a0ece60532ba09a31af2f98f00b1b573

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 (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'
    if T < R: return 'ERR_ORDER'
    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: rule evaluation order', {'res': '2027-03-25T22:45', 'ticket': '2027-03-25T21:15', 'depart': '2027-03-25T10:15', 'ap_days': 14, 'ticket_within_h': 24}, 'ERR_ORDER']], [['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: rule evaluation order', {'res': '2029-07-27T13:45', 'ticket': '2029-07-27T11:15', 'depart': '2029-07-29T18:15', 'ap_days': 21, 'ticket_within_h': 72}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2027-02-09T15:45', 'ticket': '2027-02-09T13:15', 'depart': '2027-02-10T04:15', 'ap_days': 3, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2029-02-14T16:30', 'ticket': '2029-02-14T13:30', 'depart': '2029-02-16T10:30', 'ap_days': 7, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2028-12-10T18:30', 'ticket': '2028-12-13T06:00', 'depart': '2028-12-26T10:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['regression: rule evaluation order', {'res': '2028-05-25T16:30', 'ticket': '2028-05-25T14:30', 'depart': '2028-06-02T22:30', 'ap_days': 21, 'ticket_within_h': 24}, 'ERR_ORDER']]]
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: rule evaluation orderFAIL_APERR_ORDERFailed

SHA-256 / 0f2442240c96ea01dd8f397ebd0e0f6e2ca7bfa8666d35b39119965ba2edfbea

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: rule evaluation order', {'res': '2027-03-25T22:45', 'ticket': '2027-03-25T21:15', 'depart': '2027-03-25T10:15', 'ap_days': 14, 'ticket_within_h': 24}, 'ERR_ORDER']], [['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: rule evaluation order', {'res': '2029-07-27T13:45', 'ticket': '2029-07-27T11:15', 'depart': '2029-07-29T18:15', 'ap_days': 21, 'ticket_within_h': 72}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2027-02-09T15:45', 'ticket': '2027-02-09T13:15', 'depart': '2027-02-10T04:15', 'ap_days': 3, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2029-02-14T16:30', 'ticket': '2029-02-14T13:30', 'depart': '2029-02-16T10:30', 'ap_days': 7, 'ticket_within_h': 48}, 'ERR_ORDER']], [['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'], ['regression: rule evaluation order', {'res': '2028-12-10T18:30', 'ticket': '2028-12-13T06:00', 'depart': '2028-12-26T10:00', 'ap_days': 21, 'ticket_within_h': 24}, 'FAIL_AP'], ['regression: rule evaluation order', {'res': '2028-05-25T16:30', 'ticket': '2028-05-25T14:30', 'depart': '2028-06-02T22:30', 'ap_days': 21, 'ticket_within_h': 24}, 'ERR_ORDER']]]
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: rule evaluation orderERR_ORDERERR_ORDERPassed

SHA-256 / 9e18e4f16428689fc03d7f260b40fc43fadd372c6c06666339a3a9ace9c0b5ec

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

Case digest / 51661e93dd16319bdd983087c312479cf021042c3be7357baff5ae54520c9679