FA-60686 / Loyalty points ledgers / Open access
Cancelled reward reinstatement: lot ordering · case 01
Reinstated lots are listed in source order, so the soonest-expiring lot is not shown first.
ROOT CAUSE
The output iterates lots in insertion order.
VERIFIED REPAIR
Sort reinstated lots by expiry.
Unsuccessful approach: Sorting by points shows the smallest lot first regardless of expiry.
Case contract
Input {redemption:{day, sources:[[lot_expiry, pts]]}, cancel_day, grace, max_age}. Cancelling more than max_age days after the redemption returns {"error":"too late"}. Each source lot is reinstated with its original expiry if that expiry is on or after the cancel day, otherwise with expiry cancel_day + grace. Lots with the same resulting expiry are merged. Return {lots:[[expiry,pts]] by expiry, total}.
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
N = 1
observations = []
def solve(x):
r = x['redemption']
if x['cancel_day'] - r['day'] > x['max_age']:
return {'error': 'too late'}
lots = {}
for exp, p in r['sources']:
e = exp if exp >= x['cancel_day'] else x['cancel_day'] + x['grace']
lots[e] = lots.get(e, 0) + p
return {'lots': [[e, lots[e]] for e in lots], 'total': sum(lots.values())}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed sources', {'redemption': {'day': 100, 'sources': [[91, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 51]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 51]], 'total': 51}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 102, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 11, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 101, 'grace': 14, 'max_age': 90}, {'lots': [[115, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 21], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 31], [300, 7]], 'total': 38}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 6]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 81, 'grace': 10, 'max_age': 90}, {'lots': [[91, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[92, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 52]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 52]], 'total': 52}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 103, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 12, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 102, 'grace': 14, 'max_age': 90}, {'lots': [[116, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 22], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 32], [300, 7]], 'total': 39}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 7]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 7], [150, 10], [200, 40]], 'total': 57}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 82, 'grace': 10, 'max_age': 90}, {'lots': [[92, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[93, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 53]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 53]], 'total': 53}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 104, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 13, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 103, 'grace': 14, 'max_age': 90}, {'lots': [[117, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 23], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 33], [300, 7]], 'total': 40}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 8]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 8], [150, 10], [200, 40]], 'total': 58}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 83, 'grace': 10, 'max_age': 90}, {'lots': [[93, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[94, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 54]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 54]], 'total': 54}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 105, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 14, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 104, 'grace': 14, 'max_age': 90}, {'lots': [[118, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 24], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 34], [300, 7]], 'total': 41}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 9]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 9], [150, 10], [200, 40]], 'total': 59}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 84, 'grace': 10, 'max_age': 90}, {'lots': [[94, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[95, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 55]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 55]], 'total': 55}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 106, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 15, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 105, 'grace': 14, 'max_age': 90}, {'lots': [[119, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 25], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 35], [300, 7]], 'total': 42}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 10]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 10], [150, 10], [200, 40]], 'total': 60}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 85, 'grace': 10, 'max_age': 90}, {'lots': [[95, 70]], 'total': 70}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed sources | {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600} | {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600} | Passed |
| expires on cancel day | {'lots': [[120, 51]], 'total': 51} | {'lots': [[120, 51]], 'total': 51} | Passed |
| too late | {'error': 'too late'} | {'error': 'too late'} | Passed |
| age edge | {'lots': [[500, 100], [115, 5]], 'total': 105} | {'lots': [[115, 5], [500, 100]], 'total': 105} | Failed |
| merge grace lots | {'lots': [[105, 31], [300, 7]], 'total': 38} | {'lots': [[105, 31], [300, 7]], 'total': 38} | Passed |
| merge with original | {'lots': [[200, 40], [150, 10], [90, 6]], 'total': 56} | {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56} | Failed |
| late cancel grace base | {'lots': [[91, 70]], 'total': 70} | {'lots': [[91, 70]], 'total': 70} | Passed |
SHA-256 / 740ea5bf97a306d71f9d32d1b94e84ece95ad521105e55ed72ce6f2528d40810
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
r = x['redemption']
if x['cancel_day'] - r['day'] > x['max_age']:
return {'error': 'too late'}
lots = {}
for exp, p in r['sources']:
e = exp if exp >= x['cancel_day'] else x['cancel_day'] + x['grace']
lots[e] = lots.get(e, 0) + p
return {'lots': [[e, lots[e]] for e in sorted(lots, key=lambda k: lots[k])], 'total': sum(lots.values())}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed sources', {'redemption': {'day': 100, 'sources': [[91, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 51]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 51]], 'total': 51}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 102, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 11, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 101, 'grace': 14, 'max_age': 90}, {'lots': [[115, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 21], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 31], [300, 7]], 'total': 38}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 6]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 81, 'grace': 10, 'max_age': 90}, {'lots': [[91, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[92, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 52]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 52]], 'total': 52}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 103, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 12, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 102, 'grace': 14, 'max_age': 90}, {'lots': [[116, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 22], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 32], [300, 7]], 'total': 39}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 7]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 7], [150, 10], [200, 40]], 'total': 57}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 82, 'grace': 10, 'max_age': 90}, {'lots': [[92, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[93, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 53]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 53]], 'total': 53}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 104, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 13, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 103, 'grace': 14, 'max_age': 90}, {'lots': [[117, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 23], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 33], [300, 7]], 'total': 40}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 8]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 8], [150, 10], [200, 40]], 'total': 58}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 83, 'grace': 10, 'max_age': 90}, {'lots': [[93, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[94, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 54]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 54]], 'total': 54}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 105, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 14, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 104, 'grace': 14, 'max_age': 90}, {'lots': [[118, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 24], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 34], [300, 7]], 'total': 41}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 9]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 9], [150, 10], [200, 40]], 'total': 59}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 84, 'grace': 10, 'max_age': 90}, {'lots': [[94, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[95, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 55]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 55]], 'total': 55}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 106, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 15, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 105, 'grace': 14, 'max_age': 90}, {'lots': [[119, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 25], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 35], [300, 7]], 'total': 42}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 10]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 10], [150, 10], [200, 40]], 'total': 60}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 85, 'grace': 10, 'max_age': 90}, {'lots': [[95, 70]], 'total': 70}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed sources | {'lots': [[400, 100], [150, 200], [140, 300]], 'total': 600} | {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600} | Failed |
| expires on cancel day | {'lots': [[120, 51]], 'total': 51} | {'lots': [[120, 51]], 'total': 51} | Passed |
| too late | {'error': 'too late'} | {'error': 'too late'} | Passed |
| age edge | {'lots': [[115, 5], [500, 100]], 'total': 105} | {'lots': [[115, 5], [500, 100]], 'total': 105} | Passed |
| merge grace lots | {'lots': [[300, 7], [105, 31]], 'total': 38} | {'lots': [[105, 31], [300, 7]], 'total': 38} | Failed |
| merge with original | {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56} | {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56} | Passed |
| late cancel grace base | {'lots': [[91, 70]], 'total': 70} | {'lots': [[91, 70]], 'total': 70} | Passed |
SHA-256 / a8b0e9d73deb8d1b508812a93d23e17bfc65a3a22cffe5371b5d5c5b175aedda
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
r = x['redemption']
if x['cancel_day'] - r['day'] > x['max_age']:
return {'error': 'too late'}
lots = {}
for exp, p in r['sources']:
e = exp if exp >= x['cancel_day'] else x['cancel_day'] + x['grace']
lots[e] = lots.get(e, 0) + p
return {'lots': [[e, lots[e]] for e in sorted(lots)], 'total': sum(lots.values())}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mixed sources', {'redemption': {'day': 100, 'sources': [[91, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 51]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 51]], 'total': 51}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 102, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 11, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 101, 'grace': 14, 'max_age': 90}, {'lots': [[115, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 21], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 31], [300, 7]], 'total': 38}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 6]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 81, 'grace': 10, 'max_age': 90}, {'lots': [[91, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[92, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 52]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 52]], 'total': 52}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 103, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 12, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 102, 'grace': 14, 'max_age': 90}, {'lots': [[116, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 22], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 32], [300, 7]], 'total': 39}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 7]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 7], [150, 10], [200, 40]], 'total': 57}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 82, 'grace': 10, 'max_age': 90}, {'lots': [[92, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[93, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 53]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 53]], 'total': 53}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 104, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 13, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 103, 'grace': 14, 'max_age': 90}, {'lots': [[117, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 23], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 33], [300, 7]], 'total': 40}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 8]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 8], [150, 10], [200, 40]], 'total': 58}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 83, 'grace': 10, 'max_age': 90}, {'lots': [[93, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[94, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 54]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 54]], 'total': 54}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 105, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 14, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 104, 'grace': 14, 'max_age': 90}, {'lots': [[118, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 24], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 34], [300, 7]], 'total': 41}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 9]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 9], [150, 10], [200, 40]], 'total': 59}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 84, 'grace': 10, 'max_age': 90}, {'lots': [[94, 70]], 'total': 70}]], [['mixed sources', {'redemption': {'day': 100, 'sources': [[95, 300], [150, 200], [400, 100]]}, 'cancel_day': 110, 'grace': 30, 'max_age': 90}, {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600}], ['expires on cancel day', {'redemption': {'day': 100, 'sources': [[120, 55]]}, 'cancel_day': 120, 'grace': 30, 'max_age': 90}, {'lots': [[120, 55]], 'total': 55}], ['too late', {'redemption': {'day': 10, 'sources': [[500, 100]]}, 'cancel_day': 106, 'grace': 30, 'max_age': 90}, {'error': 'too late'}], ['age edge', {'redemption': {'day': 15, 'sources': [[500, 100], [20, 5]]}, 'cancel_day': 105, 'grace': 14, 'max_age': 90}, {'lots': [[119, 5], [500, 100]], 'total': 105}], ['merge grace lots', {'redemption': {'day': 50, 'sources': [[55, 10], [58, 25], [300, 7]]}, 'cancel_day': 60, 'grace': 45, 'max_age': 90}, {'lots': [[105, 35], [300, 7]], 'total': 42}], ['merge with original', {'redemption': {'day': 50, 'sources': [[200, 40], [150, 10], [90, 10]]}, 'cancel_day': 60, 'grace': 140, 'max_age': 90}, {'lots': [[90, 10], [150, 10], [200, 40]], 'total': 60}], ['late cancel grace base', {'redemption': {'day': 20, 'sources': [[25, 70]]}, 'cancel_day': 85, 'grace': 10, 'max_age': 90}, {'lots': [[95, 70]], 'total': 70}]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| mixed sources | {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600} | {'lots': [[140, 300], [150, 200], [400, 100]], 'total': 600} | Passed |
| expires on cancel day | {'lots': [[120, 51]], 'total': 51} | {'lots': [[120, 51]], 'total': 51} | Passed |
| too late | {'error': 'too late'} | {'error': 'too late'} | Passed |
| age edge | {'lots': [[115, 5], [500, 100]], 'total': 105} | {'lots': [[115, 5], [500, 100]], 'total': 105} | Passed |
| merge grace lots | {'lots': [[105, 31], [300, 7]], 'total': 38} | {'lots': [[105, 31], [300, 7]], 'total': 38} | Passed |
| merge with original | {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56} | {'lots': [[90, 6], [150, 10], [200, 40]], 'total': 56} | Passed |
| late cancel grace base | {'lots': [[91, 70]], 'total': 70} | {'lots': [[91, 70]], 'total': 70} | Passed |
SHA-256 / 9f863b43e2301cbfca7f11ac1277af3637e48129db4959a92017a9e5826e5f6b
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:47.966978+00:00.
Case digest / 1935b33329cb256e8dcdcffe3093830a61e0931ca59c506d91112625e043e4c2