FA-59761 / Subscription proration billing / Open access
Expiring credit grants applied to invoices: consumption order · case 01
Long-lived credits are consumed while short-lived ones expire unused.
ROOT CAUSE
Grants are consumed oldest-granted first instead of soonest-expiring first.
VERIFIED REPAIR
Restore the contract rule at the consumption order step: use `usable.sort(key=lambda g: (g[1], g[2]))`.
Unsuccessful approach: The attempt sorts by expiry descending.
Case contract
Input {grants: [[amount, expires_day, granted_day]], day, amount}. A grant is usable when granted_day <= day < expires_day. Usable grants are consumed soonest-expiring first (ties by earlier grant day, then input order). Return [applied, remaining_due, [[left, expires] for partially used or untouched usable grants]].
Why this case matters
Promotional credits must be burned in expiry order and never after they expire.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
usable = [g for g in x['grants'] if g[2] <= x['day'] < g[1]]
usable.sort(key=lambda g: g[2])
need = x['amount']
applied = 0
rest = []
for amt, exp, gd in usable:
take = min(amt, need)
need -= take
applied += take
if amt - take > 0:
rest.append([amt - take, exp])
return [applied, need, rest]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'grants': [[3819, 68, 16], [1930, 58, 26], [323, 59, 3], [2345, 29, 23], [2715, 44, 13]], 'day': 44, 'amount': 5792}, [5792, 0, [[280, 68]]]), ('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('partial-repair probe', {'grants': [[2834, 10, 2], [2391, 78, 31], [4168, 56, 2], [1900, 63, 18], [3824, 30, 11]], 'day': 30, 'amount': 236}, [236, 0, [[3932, 56], [1900, 63]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('normal control', {'grants': [[1468, 59, 37], [2753, 34, 1], [3215, 49, 24]], 'day': 24, 'amount': 9315}, [5968, 3347, []]), ('normal control', {'grants': [[2342, 62, 27], [2349, 64, 11], [3400, 5, 3], [4319, 29, 10]], 'day': 3, 'amount': 11699}, [3400, 8299, []]), ('normal control', {'grants': [[2784, 49, 29], [4250, 5, 2]], 'day': 5, 'amount': 6418}, [0, 6418, []]), ('normal control', {'grants': [[2773, 15, 9], [1310, 48, 23], [4052, 71, 20]], 'day': 23, 'amount': 8492}, [5362, 3130, []])], [('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('partial-repair probe', {'grants': [[3527, 52, 33], [1461, 57, 34], [978, 47, 40], [4380, 48, 0]], 'day': 34, 'amount': 7979}, [7979, 0, [[1389, 57]]]), ('normal control', {'grants': [[1384, 70, 15], [4042, 35, 28], [3777, 37, 32], [3126, 48, 5]], 'day': 28, 'amount': 10480}, [8552, 1928, []]), ('normal control', {'grants': [[2817, 40, 9], [519, 18, 4], [2025, 35, 27]], 'day': 18, 'amount': 2988}, [2817, 171, []]), ('normal control', {'grants': [[4886, 68, 27]], 'day': 34, 'amount': 6459}, [4886, 1573, []]), ('normal control', {'grants': [[4933, 63, 40]], 'day': 63, 'amount': 7306}, [0, 7306, []])], [('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('partial-repair probe', {'grants': [[571, 50, 17], [4761, 10, 6], [3521, 82, 34], [1414, 36, 2]], 'day': 34, 'amount': 721}, [721, 0, [[693, 36], [571, 50], [3521, 82]]]), ('partial-repair probe', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('normal control', {'grants': [[348, 44, 22], [3151, 71, 29], [1829, 75, 25]], 'day': 22, 'amount': 1836}, [348, 1488, []]), ('normal control', {'grants': [[4428, 38, 34], [4352, 38, 5], [1603, 11, 10]], 'day': 38, 'amount': 11185}, [0, 11185, []]), ('normal control', {'grants': [[1532, 36, 16], [3167, 81, 23]], 'day': 79, 'amount': 9179}, [3167, 6012, []]), ('normal control', {'grants': [[1721, 49, 40], [1723, 56, 3], [735, 16, 1]], 'day': 56, 'amount': 7084}, [0, 7084, []])], [('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('partial-repair probe', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('normal control', {'grants': [], 'day': 33, 'amount': 11076}, [0, 11076, []]), ('normal control', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('normal control', {'grants': [[1110, 34, 23], [3403, 54, 35], [4357, 61, 21], [1009, 33, 4], [1988, 42, 17]], 'day': 33, 'amount': 7737}, [7455, 282, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 6225}, [0, 6225, []])], [('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('regression', {'grants': [[3971, 27, 11], [4895, 40, 6], [3338, 81, 23], [122, 78, 29], [4523, 78, 24]], 'day': 29, 'amount': 7395}, [7395, 0, [[2023, 78], [122, 78], [3338, 81]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('partial-repair probe', {'grants': [[4874, 70, 33], [4203, 58, 8]], 'day': 33, 'amount': 972}, [972, 0, [[3231, 58], [4874, 70]]]), ('normal control', {'grants': [[3265, 3, 2], [961, 90, 30], [2437, 40, 28]], 'day': 3, 'amount': 6149}, [0, 6149, []]), ('normal control', {'grants': [[1585, 58, 15], [4019, 40, 15], [2113, 83, 26]], 'day': 83, 'amount': 3346}, [0, 3346, []]), ('normal control', {'grants': [[1988, 63, 35]], 'day': 58, 'amount': 4262}, [1988, 2274, []]), ('normal control', {'grants': [[1288, 33, 20]], 'day': 20, 'amount': 7312}, [1288, 6024, []])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), 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 |
|---|---|---|---|
| regression 0 | [5792, 0, [[280, 58]]] | [5792, 0, [[280, 68]]] | Failed |
| regression 1 | [3058, 0, [[733, 45], [4651, 53], [3113, 56]]] | [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]] | Failed |
| partial-repair probe 2 | [236, 0, [[3932, 56], [1900, 63]]] | [236, 0, [[3932, 56], [1900, 63]]] | Passed |
| partial-repair probe 3 | [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]] | [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]] | Passed |
| normal control 4 | [5968, 3347, []] | [5968, 3347, []] | Passed |
| normal control 5 | [3400, 8299, []] | [3400, 8299, []] | Passed |
| normal control 6 | [0, 6418, []] | [0, 6418, []] | Passed |
| normal control 7 | [5362, 3130, []] | [5362, 3130, []] | Passed |
SHA-256 / 3ef63e6593f8c4e1fe6aa75d32673e9104100d669ad3f204e7d908a126892df3
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
usable = [g for g in x['grants'] if g[2] <= x['day'] < g[1]]
usable.sort(key=lambda g: (-g[1], g[2]))
need = x['amount']
applied = 0
rest = []
for amt, exp, gd in usable:
take = min(amt, need)
need -= take
applied += take
if amt - take > 0:
rest.append([amt - take, exp])
return [applied, need, rest]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'grants': [[3819, 68, 16], [1930, 58, 26], [323, 59, 3], [2345, 29, 23], [2715, 44, 13]], 'day': 44, 'amount': 5792}, [5792, 0, [[280, 68]]]), ('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('partial-repair probe', {'grants': [[2834, 10, 2], [2391, 78, 31], [4168, 56, 2], [1900, 63, 18], [3824, 30, 11]], 'day': 30, 'amount': 236}, [236, 0, [[3932, 56], [1900, 63]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('normal control', {'grants': [[1468, 59, 37], [2753, 34, 1], [3215, 49, 24]], 'day': 24, 'amount': 9315}, [5968, 3347, []]), ('normal control', {'grants': [[2342, 62, 27], [2349, 64, 11], [3400, 5, 3], [4319, 29, 10]], 'day': 3, 'amount': 11699}, [3400, 8299, []]), ('normal control', {'grants': [[2784, 49, 29], [4250, 5, 2]], 'day': 5, 'amount': 6418}, [0, 6418, []]), ('normal control', {'grants': [[2773, 15, 9], [1310, 48, 23], [4052, 71, 20]], 'day': 23, 'amount': 8492}, [5362, 3130, []])], [('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('partial-repair probe', {'grants': [[3527, 52, 33], [1461, 57, 34], [978, 47, 40], [4380, 48, 0]], 'day': 34, 'amount': 7979}, [7979, 0, [[1389, 57]]]), ('normal control', {'grants': [[1384, 70, 15], [4042, 35, 28], [3777, 37, 32], [3126, 48, 5]], 'day': 28, 'amount': 10480}, [8552, 1928, []]), ('normal control', {'grants': [[2817, 40, 9], [519, 18, 4], [2025, 35, 27]], 'day': 18, 'amount': 2988}, [2817, 171, []]), ('normal control', {'grants': [[4886, 68, 27]], 'day': 34, 'amount': 6459}, [4886, 1573, []]), ('normal control', {'grants': [[4933, 63, 40]], 'day': 63, 'amount': 7306}, [0, 7306, []])], [('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('partial-repair probe', {'grants': [[571, 50, 17], [4761, 10, 6], [3521, 82, 34], [1414, 36, 2]], 'day': 34, 'amount': 721}, [721, 0, [[693, 36], [571, 50], [3521, 82]]]), ('partial-repair probe', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('normal control', {'grants': [[348, 44, 22], [3151, 71, 29], [1829, 75, 25]], 'day': 22, 'amount': 1836}, [348, 1488, []]), ('normal control', {'grants': [[4428, 38, 34], [4352, 38, 5], [1603, 11, 10]], 'day': 38, 'amount': 11185}, [0, 11185, []]), ('normal control', {'grants': [[1532, 36, 16], [3167, 81, 23]], 'day': 79, 'amount': 9179}, [3167, 6012, []]), ('normal control', {'grants': [[1721, 49, 40], [1723, 56, 3], [735, 16, 1]], 'day': 56, 'amount': 7084}, [0, 7084, []])], [('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('partial-repair probe', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('normal control', {'grants': [], 'day': 33, 'amount': 11076}, [0, 11076, []]), ('normal control', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('normal control', {'grants': [[1110, 34, 23], [3403, 54, 35], [4357, 61, 21], [1009, 33, 4], [1988, 42, 17]], 'day': 33, 'amount': 7737}, [7455, 282, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 6225}, [0, 6225, []])], [('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('regression', {'grants': [[3971, 27, 11], [4895, 40, 6], [3338, 81, 23], [122, 78, 29], [4523, 78, 24]], 'day': 29, 'amount': 7395}, [7395, 0, [[2023, 78], [122, 78], [3338, 81]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('partial-repair probe', {'grants': [[4874, 70, 33], [4203, 58, 8]], 'day': 33, 'amount': 972}, [972, 0, [[3231, 58], [4874, 70]]]), ('normal control', {'grants': [[3265, 3, 2], [961, 90, 30], [2437, 40, 28]], 'day': 3, 'amount': 6149}, [0, 6149, []]), ('normal control', {'grants': [[1585, 58, 15], [4019, 40, 15], [2113, 83, 26]], 'day': 83, 'amount': 3346}, [0, 3346, []]), ('normal control', {'grants': [[1988, 63, 35]], 'day': 58, 'amount': 4262}, [1988, 2274, []]), ('normal control', {'grants': [[1288, 33, 20]], 'day': 20, 'amount': 7312}, [1288, 6024, []])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), 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 |
|---|---|---|---|
| regression 0 | [5792, 0, [[280, 58]]] | [5792, 0, [[280, 68]]] | Failed |
| regression 1 | [3058, 0, [[185, 56], [4651, 53], [3661, 45]]] | [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]] | Failed |
| partial-repair probe 2 | [236, 0, [[1664, 63], [4168, 56]]] | [236, 0, [[3932, 56], [1900, 63]]] | Failed |
| partial-repair probe 3 | [2567, 0, [[1085, 78], [3344, 61], [3775, 47]]] | [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]] | Failed |
| normal control 4 | [5968, 3347, []] | [5968, 3347, []] | Passed |
| normal control 5 | [3400, 8299, []] | [3400, 8299, []] | Passed |
| normal control 6 | [0, 6418, []] | [0, 6418, []] | Passed |
| normal control 7 | [5362, 3130, []] | [5362, 3130, []] | Passed |
SHA-256 / 2d0a24cf9ae1dfcfcbac3cbd8ad524f5b154a9dcb3f0f3bcb6d90e746710d875
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
usable = [g for g in x['grants'] if g[2] <= x['day'] < g[1]]
usable.sort(key=lambda g: (g[1], g[2]))
need = x['amount']
applied = 0
rest = []
for amt, exp, gd in usable:
take = min(amt, need)
need -= take
applied += take
if amt - take > 0:
rest.append([amt - take, exp])
return [applied, need, rest]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'grants': [[3819, 68, 16], [1930, 58, 26], [323, 59, 3], [2345, 29, 23], [2715, 44, 13]], 'day': 44, 'amount': 5792}, [5792, 0, [[280, 68]]]), ('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('partial-repair probe', {'grants': [[2834, 10, 2], [2391, 78, 31], [4168, 56, 2], [1900, 63, 18], [3824, 30, 11]], 'day': 30, 'amount': 236}, [236, 0, [[3932, 56], [1900, 63]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('normal control', {'grants': [[1468, 59, 37], [2753, 34, 1], [3215, 49, 24]], 'day': 24, 'amount': 9315}, [5968, 3347, []]), ('normal control', {'grants': [[2342, 62, 27], [2349, 64, 11], [3400, 5, 3], [4319, 29, 10]], 'day': 3, 'amount': 11699}, [3400, 8299, []]), ('normal control', {'grants': [[2784, 49, 29], [4250, 5, 2]], 'day': 5, 'amount': 6418}, [0, 6418, []]), ('normal control', {'grants': [[2773, 15, 9], [1310, 48, 23], [4052, 71, 20]], 'day': 23, 'amount': 8492}, [5362, 3130, []])], [('regression', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3652, 78, 36], [3344, 61, 28], [3775, 47, 19]], 'day': 36, 'amount': 2567}, [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]]), ('partial-repair probe', {'grants': [[3527, 52, 33], [1461, 57, 34], [978, 47, 40], [4380, 48, 0]], 'day': 34, 'amount': 7979}, [7979, 0, [[1389, 57]]]), ('normal control', {'grants': [[1384, 70, 15], [4042, 35, 28], [3777, 37, 32], [3126, 48, 5]], 'day': 28, 'amount': 10480}, [8552, 1928, []]), ('normal control', {'grants': [[2817, 40, 9], [519, 18, 4], [2025, 35, 27]], 'day': 18, 'amount': 2988}, [2817, 171, []]), ('normal control', {'grants': [[4886, 68, 27]], 'day': 34, 'amount': 6459}, [4886, 1573, []]), ('normal control', {'grants': [[4933, 63, 40]], 'day': 63, 'amount': 7306}, [0, 7306, []])], [('regression', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('partial-repair probe', {'grants': [[571, 50, 17], [4761, 10, 6], [3521, 82, 34], [1414, 36, 2]], 'day': 34, 'amount': 721}, [721, 0, [[693, 36], [571, 50], [3521, 82]]]), ('partial-repair probe', {'grants': [[4651, 53, 31], [3113, 56, 35], [1383, 36, 23], [3661, 45, 24], [130, 62, 8]], 'day': 36, 'amount': 3058}, [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]]), ('normal control', {'grants': [[348, 44, 22], [3151, 71, 29], [1829, 75, 25]], 'day': 22, 'amount': 1836}, [348, 1488, []]), ('normal control', {'grants': [[4428, 38, 34], [4352, 38, 5], [1603, 11, 10]], 'day': 38, 'amount': 11185}, [0, 11185, []]), ('normal control', {'grants': [[1532, 36, 16], [3167, 81, 23]], 'day': 79, 'amount': 9179}, [3167, 6012, []]), ('normal control', {'grants': [[1721, 49, 40], [1723, 56, 3], [735, 16, 1]], 'day': 56, 'amount': 7084}, [0, 7084, []])], [('regression', {'grants': [[402, 28, 2], [4255, 65, 36], [2572, 56, 6], [4531, 25, 19], [2694, 48, 28]], 'day': 36, 'amount': 3121}, [3121, 0, [[2145, 56], [4255, 65]]]), ('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('partial-repair probe', {'grants': [[1398, 69, 19], [4543, 47, 36], [2876, 44, 37], [4466, 58, 16]], 'day': 37, 'amount': 1446}, [1446, 0, [[1430, 44], [4543, 47], [4466, 58], [1398, 69]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('normal control', {'grants': [], 'day': 33, 'amount': 11076}, [0, 11076, []]), ('normal control', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('normal control', {'grants': [[1110, 34, 23], [3403, 54, 35], [4357, 61, 21], [1009, 33, 4], [1988, 42, 17]], 'day': 33, 'amount': 7737}, [7455, 282, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 6225}, [0, 6225, []])], [('regression', {'grants': [[3489, 77, 37], [4072, 62, 23], [470, 62, 5], [2073, 40, 29], [1072, 34, 0]], 'day': 29, 'amount': 5684}, [5684, 0, [[2003, 62]]]), ('regression', {'grants': [[3971, 27, 11], [4895, 40, 6], [3338, 81, 23], [122, 78, 29], [4523, 78, 24]], 'day': 29, 'amount': 7395}, [7395, 0, [[2023, 78], [122, 78], [3338, 81]]]), ('partial-repair probe', {'grants': [[3812, 65, 19], [1707, 52, 18], [3211, 41, 24], [3775, 75, 29], [2654, 22, 1]], 'day': 41, 'amount': 6841}, [6841, 0, [[2453, 75]]]), ('partial-repair probe', {'grants': [[4874, 70, 33], [4203, 58, 8]], 'day': 33, 'amount': 972}, [972, 0, [[3231, 58], [4874, 70]]]), ('normal control', {'grants': [[3265, 3, 2], [961, 90, 30], [2437, 40, 28]], 'day': 3, 'amount': 6149}, [0, 6149, []]), ('normal control', {'grants': [[1585, 58, 15], [4019, 40, 15], [2113, 83, 26]], 'day': 83, 'amount': 3346}, [0, 3346, []]), ('normal control', {'grants': [[1988, 63, 35]], 'day': 58, 'amount': 4262}, [1988, 2274, []]), ('normal control', {'grants': [[1288, 33, 20]], 'day': 20, 'amount': 7312}, [1288, 6024, []])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), 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 |
|---|---|---|---|
| regression 0 | [5792, 0, [[280, 68]]] | [5792, 0, [[280, 68]]] | Passed |
| regression 1 | [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]] | [3058, 0, [[603, 45], [4651, 53], [3113, 56], [130, 62]]] | Passed |
| partial-repair probe 2 | [236, 0, [[3932, 56], [1900, 63]]] | [236, 0, [[3932, 56], [1900, 63]]] | Passed |
| partial-repair probe 3 | [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]] | [2567, 0, [[1208, 47], [3344, 61], [3652, 78]]] | Passed |
| normal control 4 | [5968, 3347, []] | [5968, 3347, []] | Passed |
| normal control 5 | [3400, 8299, []] | [3400, 8299, []] | Passed |
| normal control 6 | [0, 6418, []] | [0, 6418, []] | Passed |
| normal control 7 | [5362, 3130, []] | [5362, 3130, []] | Passed |
SHA-256 / 266f12891f9eb98193e209e171e73ebd713c3712aa50a10035a83fe57648a0f0
Verification & scope
A deterministic teaching model of a stipulated billing rule. It makes no claim to reproduce any billing provider's exact behaviour and is not billing software. 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:39.391356+00:00.
Case digest / d7837890d9c09e6656c55480c3f46b4bee006f25177ec2e03754231596ff80f7