FAILURE MAP
← Case archive

FA-60706 / Loyalty points ledgers / Open access

Birthday bonus window: once-per-year key · case 01

A member receives two bonuses for one birthday when purchases straddle New Year.

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

ROOT CAUSE

The once-per-year guard is keyed by purchase year instead of birthday year.

VERIFIED REPAIR

Key the guard by the birthday year that matched.

Unsuccessful approach: Allowing only one bonus ever blocks every later birthday.

Case contract

Input {bmonth, bday, window, bonus, purchases:[[y,m,d]] chronological}. The birthday of year Y is (Y,bmonth,bday), with Feb 29 falling back to Feb 28 in non-leap years (Gregorian rule). A purchase within window days (inclusive, either side) of the birthday of year Y-1, Y or Y+1 earns the bonus once per birthday year. Return per-purchase bonus list.

Why this case matters

Member point balances, statements and the program liability depend on this ledger rule.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    def bday(y):
        m, d = x['bmonth'], x['bday']
        if m == 2 and d == 29 and not (y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)):
            d = 28
        return datetime.date(y, m, d)
    got = set()
    out = []
    for y, m, d in x['purchases']:
        p = datetime.date(y, m, d)
        award = 0
        for yy in (y - 1, y, y + 1):
            if abs((p - bday(yy)).days) <= x['window'] and y not in got:
                got.add(y)
                award = x['bonus']
                break
        out.append(award)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 11], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 8]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 801, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [801, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 21], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 41, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [41, 41]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 12], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 9]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 802, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [802, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 22], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 42, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [42, 42]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 13], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 10]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 28], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 803, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [803, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 23], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 43, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [43, 43]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 14], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 11]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 804, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [804, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 24], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 44, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [44, 44]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 15], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 12]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 805, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [805, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 25], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 45, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [45, 45]]]]
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
inside window[500, 0][500, 0]Passed
window edge[500, 0][500, 0]Passed
year crossing[300, 300][300, 0]Failed
late december birthday[250, 0][250, 250]Failed
leap day[800, 800, 0][800, 800, 0]Passed
century year[801, 0][801, 0]Passed
before birthday only[0, 100, 0][0, 100, 0]Passed
two years[41, 41][41, 41]Passed

SHA-256 / 647aa8150a66f07d83afa2f5eb58c11b50f8f8f0d8d534ee34c8fb83469523bc

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    def bday(y):
        m, d = x['bmonth'], x['bday']
        if m == 2 and d == 29 and not (y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)):
            d = 28
        return datetime.date(y, m, d)
    got = set()
    out = []
    for y, m, d in x['purchases']:
        p = datetime.date(y, m, d)
        award = 0
        for yy in (y - 1, y, y + 1):
            if abs((p - bday(yy)).days) <= x['window'] and not got:
                got.add(yy)
                award = x['bonus']
                break
        out.append(award)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 11], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 8]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 801, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [801, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 21], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 41, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [41, 41]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 12], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 9]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 802, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [802, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 22], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 42, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [42, 42]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 13], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 10]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 28], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 803, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [803, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 23], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 43, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [43, 43]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 14], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 11]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 804, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [804, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 24], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 44, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [44, 44]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 15], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 12]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 805, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [805, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 25], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 45, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [45, 45]]]]
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
inside window[500, 0][500, 0]Passed
window edge[500, 0][500, 0]Passed
year crossing[300, 0][300, 0]Passed
late december birthday[250, 0][250, 250]Failed
leap day[800, 0, 0][800, 800, 0]Failed
century year[801, 0][801, 0]Passed
before birthday only[0, 100, 0][0, 100, 0]Passed
two years[41, 0][41, 41]Failed

SHA-256 / 70550e59347ccf76aba679dbf892a1eb239e371c6a2d59fdac3c983dea9c4fce

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    def bday(y):
        m, d = x['bmonth'], x['bday']
        if m == 2 and d == 29 and not (y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)):
            d = 28
        return datetime.date(y, m, d)
    got = set()
    out = []
    for y, m, d in x['purchases']:
        p = datetime.date(y, m, d)
        award = 0
        for yy in (y - 1, y, y + 1):
            if abs((p - bday(yy)).days) <= x['window'] and yy not in got:
                got.add(yy)
                award = x['bonus']
                break
        out.append(award)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 11], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 8]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 801, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [801, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 21], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 41, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [41, 41]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 12], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 9]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 802, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [802, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 22], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 42, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [42, 42]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 13], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 10]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 28], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 803, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [803, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 23], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 43, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [43, 43]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 14], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 11]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 29], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 2], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 804, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [804, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 24], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 44, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [44, 44]]], [['inside window', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2024, 6, 15], [2024, 6, 20]]}, [500, 0]], ['window edge', {'bmonth': 6, 'bday': 15, 'window': 7, 'bonus': 500, 'purchases': [[2023, 6, 22], [2023, 6, 12]]}, [500, 0]], ['year crossing', {'bmonth': 1, 'bday': 3, 'window': 7, 'bonus': 300, 'purchases': [[2023, 12, 30], [2024, 1, 5]]}, [300, 0]], ['late december birthday', {'bmonth': 12, 'bday': 30, 'window': 5, 'bonus': 250, 'purchases': [[2025, 1, 3], [2025, 12, 29]]}, [250, 250]], ['leap day', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 800, 'purchases': [[2023, 2, 28], [2024, 2, 29], [2023, 3, 1]]}, [800, 800, 0]], ['century year', {'bmonth': 2, 'bday': 29, 'window': 0, 'bonus': 805, 'purchases': [[2100, 2, 28], [2100, 3, 1]]}, [805, 0]], ['before birthday only', {'bmonth': 9, 'bday': 1, 'window': 3, 'bonus': 100, 'purchases': [[2024, 8, 25], [2024, 8, 30], [2024, 9, 3]]}, [0, 100, 0]], ['two years', {'bmonth': 5, 'bday': 5, 'window': 2, 'bonus': 45, 'purchases': [[2022, 5, 5], [2023, 5, 6]]}, [45, 45]]]]
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
inside window[500, 0][500, 0]Passed
window edge[500, 0][500, 0]Passed
year crossing[300, 0][300, 0]Passed
late december birthday[250, 250][250, 250]Passed
leap day[800, 800, 0][800, 800, 0]Passed
century year[801, 0][801, 0]Passed
before birthday only[0, 100, 0][0, 100, 0]Passed
two years[41, 41][41, 41]Passed

SHA-256 / 8e2920ab936c8b7829f51833982c4d2e3c3e3b942bc66091e879fe06ae1e0be2

Verification & scope

Stipulated bounded loyalty-program model with explicit toy rules; not any real program terms. 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:46:48.072787+00:00.

Case digest / 3113d01a22733ebbd48db97661211cd88b3345846d4e7bbd2881f39e682f9682