FAILURE MAP
← Case archive

FA-66686 / Airline fare rule evaluation / Open access

Outbound-only surcharge rule charged on return · case 01

Fares with an OUTBOUND rule add a second weekend surcharge on the return.

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

ROOT CAUSE

The inbound assessment ignores the rt_rule.

THE FAILURE

The inbound assessment ignores the rt_rule.

Unsuccessful approach: Testing for a NONE rule still treats OUTBOUND as EACH.

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:
        total += sur(x['inbound'])
    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 back5050Passed
weekend out weekday back2525Passed
outbound-only rule6030Failed
one-way weekend9090Passed
both weekend family160160Passed
no surcharge00Passed
sampled case 1125125Passed
sampled case 24040Passed
sampled case 31010Passed

SHA-256 / 5d4fc3af5a0596b7f26819123874adde8eaa2ad231619540237a2695f1699bfd

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'] != 'NONE':
        total += sur(x['inbound'])
    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 back5050Passed
weekend out weekday back2525Passed
outbound-only rule6030Failed
one-way weekend9090Passed
both weekend family160160Passed
no surcharge00Passed
sampled case 1125125Passed
sampled case 24040Passed
sampled case 31010Passed

SHA-256 / 5654830490325377e722c4f530e1b34efe4519a4ec1c7196977f6fc5372d8688

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 / 1a8e0f0353a5fef158fbf1b6f7561dd2f3c2a0f942356a3a608d3ef0db920d38