FA-60476 / Loyalty points ledgers / Open access
Refund points clawback: debt accumulation · case 01
Only the most recent shortfall is shown as debt after several refunds.
ROOT CAUSE
Debt is overwritten by each refund shortfall instead of accumulated.
VERIFIED REPAIR
Add each shortfall to the running debt.
Unsuccessful approach: Keeping the largest single shortfall still understates total debt.
Case contract
Input {earned, order_total, refunds:[cents], balance}. Cumulative refunds are capped at the order total. After each refund the cumulative clawback target is round-half-up(earned*cumulative refund/order total); the refund claws target minus already clawed. A clawback is taken from the balance only down to zero; the shortfall accumulates as debt. Return {claws, balance, debt}.
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):
cum = 0
clawed = 0
bal = x['balance']
debt = 0
out = []
for r in x['refunds']:
cum = min(x['order_total'], cum + r)
target = (2 * x['earned'] * cum + x['order_total']) // (2 * x['order_total'])
c = target - clawed
clawed = target
take = min(c, bal)
bal -= take
debt = c - take
out.append(c)
return {'claws': out, 'balance': bal, 'debt': debt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2501], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 51}, {'claws': [3, 4, 3], 'balance': 41, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3001], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 31}, {'claws': [100, 100], 'balance': 0, 'debt': 169}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 1}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 89}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 11}, {'claws': [2], 'balance': 9, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [2], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2502], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 52}, {'claws': [3, 4, 3], 'balance': 42, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3002], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 32}, {'claws': [100, 100], 'balance': 0, 'debt': 168}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 2}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 88}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 12}, {'claws': [2], 'balance': 10, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [3], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2503], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 53}, {'claws': [3, 4, 3], 'balance': 43, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3003], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 33}, {'claws': [100, 100], 'balance': 0, 'debt': 167}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 3}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 87}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 13}, {'claws': [2], 'balance': 11, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [4], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2504], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 54}, {'claws': [3, 4, 3], 'balance': 44, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3004], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 34}, {'claws': [100, 100], 'balance': 0, 'debt': 166}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 4}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 86}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 14}, {'claws': [2], 'balance': 12, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [5], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2505], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 55}, {'claws': [3, 4, 3], 'balance': 45, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3005], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 35}, {'claws': [100, 100], 'balance': 0, 'debt': 165}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 5}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 85}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 15}, {'claws': [2], 'balance': 13, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [6], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]]]
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 |
|---|---|---|---|
| two partial refunds | {'balance': 937, 'claws': [31, 32], 'debt': 0} | {'balance': 937, 'claws': [31, 32], 'debt': 0} | Passed |
| rounding drift | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | Passed |
| over refund | {'balance': 420, 'claws': [60, 20], 'debt': 0} | {'balance': 420, 'claws': [60, 20], 'debt': 0} | Passed |
| spent points | {'balance': 0, 'claws': [100, 100], 'debt': 100} | {'balance': 0, 'claws': [100, 100], 'debt': 169} | Failed |
| debt grows | {'balance': 0, 'claws': [30, 30, 30], 'debt': 30} | {'balance': 0, 'claws': [30, 30, 30], 'debt': 89} | Failed |
| single half | {'balance': 9, 'claws': [2], 'debt': 0} | {'balance': 9, 'claws': [2], 'debt': 0} | Passed |
| refund one of many | {'balance': 5, 'claws': [0], 'debt': 0} | {'balance': 5, 'claws': [0], 'debt': 0} | Passed |
SHA-256 / e62fbd09c8fe5dcc435f78f9fb771cdfcec920322756d2ff137a2914255d3135
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cum = 0
clawed = 0
bal = x['balance']
debt = 0
out = []
for r in x['refunds']:
cum = min(x['order_total'], cum + r)
target = (2 * x['earned'] * cum + x['order_total']) // (2 * x['order_total'])
c = target - clawed
clawed = target
take = min(c, bal)
bal -= take
debt = max(debt, c - take)
out.append(c)
return {'claws': out, 'balance': bal, 'debt': debt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2501], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 51}, {'claws': [3, 4, 3], 'balance': 41, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3001], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 31}, {'claws': [100, 100], 'balance': 0, 'debt': 169}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 1}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 89}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 11}, {'claws': [2], 'balance': 9, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [2], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2502], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 52}, {'claws': [3, 4, 3], 'balance': 42, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3002], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 32}, {'claws': [100, 100], 'balance': 0, 'debt': 168}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 2}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 88}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 12}, {'claws': [2], 'balance': 10, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [3], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2503], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 53}, {'claws': [3, 4, 3], 'balance': 43, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3003], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 33}, {'claws': [100, 100], 'balance': 0, 'debt': 167}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 3}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 87}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 13}, {'claws': [2], 'balance': 11, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [4], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2504], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 54}, {'claws': [3, 4, 3], 'balance': 44, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3004], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 34}, {'claws': [100, 100], 'balance': 0, 'debt': 166}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 4}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 86}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 14}, {'claws': [2], 'balance': 12, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [5], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2505], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 55}, {'claws': [3, 4, 3], 'balance': 45, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3005], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 35}, {'claws': [100, 100], 'balance': 0, 'debt': 165}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 5}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 85}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 15}, {'claws': [2], 'balance': 13, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [6], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]]]
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 |
|---|---|---|---|
| two partial refunds | {'balance': 937, 'claws': [31, 32], 'debt': 0} | {'balance': 937, 'claws': [31, 32], 'debt': 0} | Passed |
| rounding drift | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | Passed |
| over refund | {'balance': 420, 'claws': [60, 20], 'debt': 0} | {'balance': 420, 'claws': [60, 20], 'debt': 0} | Passed |
| spent points | {'balance': 0, 'claws': [100, 100], 'debt': 100} | {'balance': 0, 'claws': [100, 100], 'debt': 169} | Failed |
| debt grows | {'balance': 0, 'claws': [30, 30, 30], 'debt': 30} | {'balance': 0, 'claws': [30, 30, 30], 'debt': 89} | Failed |
| single half | {'balance': 9, 'claws': [2], 'debt': 0} | {'balance': 9, 'claws': [2], 'debt': 0} | Passed |
| refund one of many | {'balance': 5, 'claws': [0], 'debt': 0} | {'balance': 5, 'claws': [0], 'debt': 0} | Passed |
SHA-256 / 1b500368ee556a4a0879483e1b9c06682ffb1e409d42796966c76c8c3aa947a0
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
cum = 0
clawed = 0
bal = x['balance']
debt = 0
out = []
for r in x['refunds']:
cum = min(x['order_total'], cum + r)
target = (2 * x['earned'] * cum + x['order_total']) // (2 * x['order_total'])
c = target - clawed
clawed = target
take = min(c, bal)
bal -= take
debt += c - take
out.append(c)
return {'claws': out, 'balance': bal, 'debt': debt}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2501], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 51}, {'claws': [3, 4, 3], 'balance': 41, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3001], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 31}, {'claws': [100, 100], 'balance': 0, 'debt': 169}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 1}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 89}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 11}, {'claws': [2], 'balance': 9, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [2], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2502], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 52}, {'claws': [3, 4, 3], 'balance': 42, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3002], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 32}, {'claws': [100, 100], 'balance': 0, 'debt': 168}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 2}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 88}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 12}, {'claws': [2], 'balance': 10, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [3], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2503], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 53}, {'claws': [3, 4, 3], 'balance': 43, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3003], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 33}, {'claws': [100, 100], 'balance': 0, 'debt': 167}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 3}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 87}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 13}, {'claws': [2], 'balance': 11, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [4], 'balance': 5}, {'claws': [0], 'balance': 5, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2504], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 54}, {'claws': [3, 4, 3], 'balance': 44, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3004], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 34}, {'claws': [100, 100], 'balance': 0, 'debt': 166}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 4}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 86}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 14}, {'claws': [2], 'balance': 12, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [5], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]], [['two partial refunds', {'earned': 125, 'order_total': 10000, 'refunds': [2500, 2505], 'balance': 1000}, {'claws': [31, 32], 'balance': 937, 'debt': 0}], ['rounding drift', {'earned': 10, 'order_total': 300, 'refunds': [100, 100, 100], 'balance': 55}, {'claws': [3, 4, 3], 'balance': 45, 'debt': 0}], ['over refund', {'earned': 80, 'order_total': 4000, 'refunds': [3000, 3005], 'balance': 500}, {'claws': [60, 20], 'balance': 420, 'debt': 0}], ['spent points', {'earned': 200, 'order_total': 2000, 'refunds': [1000, 1000], 'balance': 35}, {'claws': [100, 100], 'balance': 0, 'debt': 165}], ['debt grows', {'earned': 90, 'order_total': 900, 'refunds': [300, 300, 300], 'balance': 5}, {'claws': [30, 30, 30], 'balance': 0, 'debt': 85}], ['single half', {'earned': 3, 'order_total': 2, 'refunds': [1], 'balance': 15}, {'claws': [2], 'balance': 13, 'debt': 0}], ['refund one of many', {'earned': 999, 'order_total': 9990, 'refunds': [6], 'balance': 5}, {'claws': [1], 'balance': 4, 'debt': 0}]]]
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 |
|---|---|---|---|
| two partial refunds | {'balance': 937, 'claws': [31, 32], 'debt': 0} | {'balance': 937, 'claws': [31, 32], 'debt': 0} | Passed |
| rounding drift | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | {'balance': 41, 'claws': [3, 4, 3], 'debt': 0} | Passed |
| over refund | {'balance': 420, 'claws': [60, 20], 'debt': 0} | {'balance': 420, 'claws': [60, 20], 'debt': 0} | Passed |
| spent points | {'balance': 0, 'claws': [100, 100], 'debt': 169} | {'balance': 0, 'claws': [100, 100], 'debt': 169} | Passed |
| debt grows | {'balance': 0, 'claws': [30, 30, 30], 'debt': 89} | {'balance': 0, 'claws': [30, 30, 30], 'debt': 89} | Passed |
| single half | {'balance': 9, 'claws': [2], 'debt': 0} | {'balance': 9, 'claws': [2], 'debt': 0} | Passed |
| refund one of many | {'balance': 5, 'claws': [0], 'debt': 0} | {'balance': 5, 'claws': [0], 'debt': 0} | Passed |
SHA-256 / a35503a4c5cf2bb85d534cf4801183d2da562e84e17369c56a823ef028b36be0
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:45.989024+00:00.
Case digest / 498c7bdfba5140cee2bf3997a0ab11ccb07a2094776e57895f455932cfc8d6c3