FAILURE MAP
← Case archive

FA-66681 / Airline fare rule evaluation / Open access

Inbound surcharge decided by the outbound date · case 01

A weekend return after a weekday departure is not surcharged, while a weekday return after a weekend departure is.

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

ROOT CAUSE

The inbound assessment reads the outbound date.

THE FAILURE

The inbound assessment reads the outbound date.

Unsuccessful approach: Surcharging the inbound only when the outbound was surcharged still ties it to the outbound day.

Case contract

Input {'outbound','inbound' (ISO or None),'weekend_days' ISO digits,'surcharge','rt_rule' EACH|OUTBOUND,'pax'}. Each direction is surcharged by its own departure weekday; with OUTBOUND only the outbound direction is assessed. The per-passenger total is multiplied by pax.

Why this case matters

Day-of-week surcharges are assessed per fare component on its own travel date, and the rule may restrict assessment to the outbound direction.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['outbound'])
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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
weekday out weekend back050Failed
weekend out weekday back5025Failed
outbound-only rule3030Passed
one-way weekend9090Passed
both weekend family160160Passed
no surcharge00Passed
sampled case 1250125Failed
sampled case 2040Failed
sampled case 32010Failed

SHA-256 / 97d8e9333862cf2e31d381c853e78e637616b2b6c504b020931d70ff4fb0f1d0

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['inbound']) if total else 0
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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
weekday out weekend back050Failed
weekend out weekday back2525Passed
outbound-only rule3030Passed
one-way weekend9090Passed
both weekend family160160Passed
no surcharge00Passed
sampled case 1125125Passed
sampled case 2040Failed
sampled case 31010Passed

SHA-256 / fa1f3d92113f4ea1717b9038fe6a8362221c57612fad2a4f4c7b2c488b09e9ec

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 9 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 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:46.182048+00:00.

Case digest / 50e0ed51267b233f955a6b17c23e916a2302b13c938670e8dfbee4e072ac16df