FA-60726 / Loyalty points ledgers / Open access
Monthly promotional bonus cap: base points consume cap · case 01
Large purchases exhaust the bonus cap with base points.
ROOT CAUSE
Base points are added to the monthly cap counter.
VERIFIED REPAIR
Only awarded regular bonus counts toward the cap.
Unsuccessful approach: Counting the larger of base or bonus still charges base points to the cap.
Case contract
Input {cap, txns:[[yyyy-mm, base, bonus, exempt_bonus]]}. Base points are never capped. Regular bonus points are capped per calendar month: each transaction receives min(bonus, cap - bonus already awarded that month). Exempt bonus is always awarded and never uses the cap. Return {awards (base + awarded bonus + exempt per txn), 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):
used = {}
out = []
for m, base, bonus, exempt in x['txns']:
k = m
rem = x['cap'] - used.get(k, 0)
b = min(bonus, rem)
used[k] = used.get(k, 0) + b + base
out.append(base + b + exempt)
return {'awards': out, 'total': sum(out)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2501, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1001, 0]]}, {'awards': [5000, 1001], 'total': 6001}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 901, 0]]}, {'awards': [905, 906], 'total': 1811}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 401, 0]]}, {'awards': [2400, 601], 'total': 3001}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 301, 0]]}, {'awards': [5600, 3301], 'total': 8901}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 251], ['2024-05', 1, 90, 0]]}, {'awards': [252, 91], 'total': 343}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 101, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2502, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1002, 0]]}, {'awards': [5000, 1002], 'total': 6002}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 902, 0]]}, {'awards': [905, 907], 'total': 1812}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 402, 0]]}, {'awards': [2400, 602], 'total': 3002}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 302, 0]]}, {'awards': [5600, 3302], 'total': 8902}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 252], ['2024-05', 1, 90, 0]]}, {'awards': [253, 91], 'total': 344}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 102, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2503, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1003, 0]]}, {'awards': [5000, 1003], 'total': 6003}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 903, 0]]}, {'awards': [905, 908], 'total': 1813}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 403, 0]]}, {'awards': [2400, 603], 'total': 3003}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 303, 0]]}, {'awards': [5600, 3303], 'total': 8903}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 253], ['2024-05', 1, 90, 0]]}, {'awards': [254, 91], 'total': 345}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 103, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2504, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1004, 0]]}, {'awards': [5000, 1004], 'total': 6004}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 904, 0]]}, {'awards': [905, 909], 'total': 1814}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 404, 0]]}, {'awards': [2400, 604], 'total': 3004}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 304, 0]]}, {'awards': [5600, 3304], 'total': 8904}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 254], ['2024-05', 1, 90, 0]]}, {'awards': [255, 91], 'total': 346}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 104, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2505, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1005, 0]]}, {'awards': [5000, 1005], 'total': 6005}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 905, 0]]}, {'awards': [905, 910], 'total': 1815}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 405, 0]]}, {'awards': [2400, 605], 'total': 3005}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 305, 0]]}, {'awards': [5600, 3305], 'total': 8905}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 255], ['2024-05', 1, 90, 0]]}, {'awards': [256, 91], 'total': 347}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 105, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]]]
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 |
|---|---|---|---|
| cap within month | {'awards': [3100, 1950, -40], 'total': 5010} | {'awards': [3100, 2050, 10], 'total': 5160} | Failed |
| new month resets | {'awards': [5000, 1001], 'total': 6001} | {'awards': [5000, 1001], 'total': 6001} | Passed |
| same month next year | {'awards': [905, 906], 'total': 1811} | {'awards': [905, 906], 'total': 1811} | Passed |
| exempt promo | {'awards': [2400, 500], 'total': 2900} | {'awards': [2400, 601], 'total': 3001} | Failed |
| base never capped | {'awards': [5600, -1600], 'total': 4000} | {'awards': [5600, 3301], 'total': 8901} | Failed |
| exempt only | {'awards': [252, 91], 'total': 343} | {'awards': [252, 91], 'total': 343} | Passed |
| many small | {'awards': [101, 102, 99, 0], 'total': 302} | {'awards': [101, 102, 101, 1], 'total': 305} | Failed |
SHA-256 / 3680687677d51d0b78758ee308271dac4b83db99a8aa8f31e0e1113d337962e2
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
used = {}
out = []
for m, base, bonus, exempt in x['txns']:
k = m
rem = x['cap'] - used.get(k, 0)
b = min(bonus, rem)
used[k] = used.get(k, 0) + max(b, base)
out.append(base + b + exempt)
return {'awards': out, 'total': sum(out)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2501, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1001, 0]]}, {'awards': [5000, 1001], 'total': 6001}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 901, 0]]}, {'awards': [905, 906], 'total': 1811}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 401, 0]]}, {'awards': [2400, 601], 'total': 3001}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 301, 0]]}, {'awards': [5600, 3301], 'total': 8901}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 251], ['2024-05', 1, 90, 0]]}, {'awards': [252, 91], 'total': 343}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 101, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2502, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1002, 0]]}, {'awards': [5000, 1002], 'total': 6002}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 902, 0]]}, {'awards': [905, 907], 'total': 1812}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 402, 0]]}, {'awards': [2400, 602], 'total': 3002}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 302, 0]]}, {'awards': [5600, 3302], 'total': 8902}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 252], ['2024-05', 1, 90, 0]]}, {'awards': [253, 91], 'total': 344}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 102, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2503, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1003, 0]]}, {'awards': [5000, 1003], 'total': 6003}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 903, 0]]}, {'awards': [905, 908], 'total': 1813}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 403, 0]]}, {'awards': [2400, 603], 'total': 3003}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 303, 0]]}, {'awards': [5600, 3303], 'total': 8903}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 253], ['2024-05', 1, 90, 0]]}, {'awards': [254, 91], 'total': 345}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 103, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2504, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1004, 0]]}, {'awards': [5000, 1004], 'total': 6004}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 904, 0]]}, {'awards': [905, 909], 'total': 1814}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 404, 0]]}, {'awards': [2400, 604], 'total': 3004}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 304, 0]]}, {'awards': [5600, 3304], 'total': 8904}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 254], ['2024-05', 1, 90, 0]]}, {'awards': [255, 91], 'total': 346}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 104, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2505, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1005, 0]]}, {'awards': [5000, 1005], 'total': 6005}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 905, 0]]}, {'awards': [905, 910], 'total': 1815}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 405, 0]]}, {'awards': [2400, 605], 'total': 3005}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 305, 0]]}, {'awards': [5600, 3305], 'total': 8905}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 255], ['2024-05', 1, 90, 0]]}, {'awards': [256, 91], 'total': 347}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 105, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]]]
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 |
|---|---|---|---|
| cap within month | {'awards': [3100, 2050, 10], 'total': 5160} | {'awards': [3100, 2050, 10], 'total': 5160} | Passed |
| new month resets | {'awards': [5000, 1001], 'total': 6001} | {'awards': [5000, 1001], 'total': 6001} | Passed |
| same month next year | {'awards': [905, 906], 'total': 1811} | {'awards': [905, 906], 'total': 1811} | Passed |
| exempt promo | {'awards': [2400, 601], 'total': 3001} | {'awards': [2400, 601], 'total': 3001} | Passed |
| base never capped | {'awards': [5600, -1000], 'total': 4600} | {'awards': [5600, 3301], 'total': 8901} | Failed |
| exempt only | {'awards': [252, 91], 'total': 343} | {'awards': [252, 91], 'total': 343} | Passed |
| many small | {'awards': [101, 102, 101, 1], 'total': 305} | {'awards': [101, 102, 101, 1], 'total': 305} | Passed |
SHA-256 / 65590c6e918108276a0cb459dd9a8356690f6fcc6040c59e7bf5d1e87a65ff14
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
used = {}
out = []
for m, base, bonus, exempt in x['txns']:
k = m
rem = x['cap'] - used.get(k, 0)
b = min(bonus, rem)
used[k] = used.get(k, 0) + b
out.append(base + b + exempt)
return {'awards': out, 'total': sum(out)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2501, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1001, 0]]}, {'awards': [5000, 1001], 'total': 6001}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 901, 0]]}, {'awards': [905, 906], 'total': 1811}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 401, 0]]}, {'awards': [2400, 601], 'total': 3001}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 301, 0]]}, {'awards': [5600, 3301], 'total': 8901}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 251], ['2024-05', 1, 90, 0]]}, {'awards': [252, 91], 'total': 343}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 101, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2502, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1002, 0]]}, {'awards': [5000, 1002], 'total': 6002}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 902, 0]]}, {'awards': [905, 907], 'total': 1812}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 402, 0]]}, {'awards': [2400, 602], 'total': 3002}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 302, 0]]}, {'awards': [5600, 3302], 'total': 8902}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 252], ['2024-05', 1, 90, 0]]}, {'awards': [253, 91], 'total': 344}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 102, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2503, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1003, 0]]}, {'awards': [5000, 1003], 'total': 6003}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 903, 0]]}, {'awards': [905, 908], 'total': 1813}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 403, 0]]}, {'awards': [2400, 603], 'total': 3003}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 303, 0]]}, {'awards': [5600, 3303], 'total': 8903}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 253], ['2024-05', 1, 90, 0]]}, {'awards': [254, 91], 'total': 345}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 103, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2504, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1004, 0]]}, {'awards': [5000, 1004], 'total': 6004}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 904, 0]]}, {'awards': [905, 909], 'total': 1814}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 404, 0]]}, {'awards': [2400, 604], 'total': 3004}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 304, 0]]}, {'awards': [5600, 3304], 'total': 8904}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 254], ['2024-05', 1, 90, 0]]}, {'awards': [255, 91], 'total': 346}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 104, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]], [['cap within month', {'cap': 5000, 'txns': [['2024-03', 100, 3000, 0], ['2024-03', 50, 2505, 0], ['2024-03', 10, 400, 0]]}, {'awards': [3100, 2050, 10], 'total': 5160}], ['new month resets', {'cap': 5000, 'txns': [['2024-03', 0, 5000, 0], ['2024-04', 0, 1005, 0]]}, {'awards': [5000, 1005], 'total': 6005}], ['same month next year', {'cap': 1000, 'txns': [['2023-07', 5, 900, 0], ['2024-07', 5, 905, 0]]}, {'awards': [905, 910], 'total': 1815}], ['exempt promo', {'cap': 2000, 'txns': [['2024-01', 200, 1500, 700], ['2024-01', 200, 405, 0]]}, {'awards': [2400, 605], 'total': 3005}], ['base never capped', {'cap': 1000, 'txns': [['2024-02', 5000, 600, 0], ['2024-02', 3000, 305, 0]]}, {'awards': [5600, 3305], 'total': 8905}], ['exempt only', {'cap': 100, 'txns': [['2024-05', 1, 0, 255], ['2024-05', 1, 90, 0]]}, {'awards': [256, 91], 'total': 347}], ['many small', {'cap': 300, 'txns': [['2024-06', 1, 100, 0], ['2024-06', 1, 100, 1], ['2024-06', 1, 105, 0], ['2024-06', 1, 100, 0]]}, {'awards': [101, 102, 101, 1], 'total': 305}]]]
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 |
|---|---|---|---|
| cap within month | {'awards': [3100, 2050, 10], 'total': 5160} | {'awards': [3100, 2050, 10], 'total': 5160} | Passed |
| new month resets | {'awards': [5000, 1001], 'total': 6001} | {'awards': [5000, 1001], 'total': 6001} | Passed |
| same month next year | {'awards': [905, 906], 'total': 1811} | {'awards': [905, 906], 'total': 1811} | Passed |
| exempt promo | {'awards': [2400, 601], 'total': 3001} | {'awards': [2400, 601], 'total': 3001} | Passed |
| base never capped | {'awards': [5600, 3301], 'total': 8901} | {'awards': [5600, 3301], 'total': 8901} | Passed |
| exempt only | {'awards': [252, 91], 'total': 343} | {'awards': [252, 91], 'total': 343} | Passed |
| many small | {'awards': [101, 102, 101, 1], 'total': 305} | {'awards': [101, 102, 101, 1], 'total': 305} | Passed |
SHA-256 / 04b65353a5c3f310ece00e881a23156cdde5dac6c46795cc80a2a196dcd61f7e
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.290984+00:00.
Case digest / ae2e81ff42be03a7f358e904197785622b3808684681a412510ecac539314130