FAILURE MAP
← Case archive

FA-59436 / Subscription proration billing / Open access

Coupons on invoices with proration lines: repeating coupon window · case 01

A three-month coupon discounts a fourth invoice.

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

ROOT CAUSE

The repeating duration test is inclusive of the month count.

VERIFIED REPAIR

Restore the contract rule at the repeating coupon window step: use `x['idx'] < c['months']`.

Unsuccessful approach: The attempt ends the coupon one invoice early.

Case contract

Input {lines: signed cents, coupon {type percent|amount, value, duration once|repeating|forever, months}, idx (0-based invoice number since redemption)}. Coupon active: forever always; once only at idx 0; repeating while idx < months. Percent coupons discount each positive line separately (half-up); credit lines are not discounted. Amount coupons subtract value capped at the sum of positive lines. Total = sum(lines) - discount. Return [discount, amount_due = max(0,total), credit = max(0,-total)].

Why this case matters

Coupons interact with proration credits; discounting a credit line or over-applying an amount-off coupon changes what customers pay.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    c = x['coupon']
    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] <= c['months'])
    pos = [a for a in x['lines'] if a > 0]
    discount = 0
    if active:
        if c['type'] == 'percent':
            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)
        else:
            discount = min(c['value'], sum(pos))
    total = sum(x['lines']) - discount
    return [discount, max(0, total), max(0, -total)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'lines': [791], 'coupon': {'type': 'percent', 'value': 15, 'duration': 'repeating', 'months': 1}, 'idx': 1}, [0, 791, 0]), ('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('partial-repair probe', {'lines': [27067, -9430, 18496, 15243, 566], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [20253, 31689, 0]), ('partial-repair probe', {'lines': [463, 18993, 591, 25859, 508], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [500, 45914, 0]), ('normal control', {'lines': [-9318], 'coupon': {'type': 'amount', 'value': 29602, 'duration': 'forever', 'months': 3}, 'idx': 7}, [0, 0, 9318]), ('normal control', {'lines': [165], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'once', 'months': 3}, 'idx': 4}, [0, 165, 0]), ('normal control', {'lines': [32449, 5413], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 4}, [2000, 35862, 0]), ('normal control', {'lines': [-19181, 10683, -19030, -24033], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 1}, 'idx': 5}, [0, 0, 51561])], [('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('partial-repair probe', {'lines': [73], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [24, 49, 0]), ('partial-repair probe', {'lines': [-7260, 406], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [406, 0, 7260]), ('normal control', {'lines': [765], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 1}, [765, 0, 0]), ('normal control', {'lines': [196, 15845, -4816, 575, 15297], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 2}, 'idx': 6}, [2000, 25097, 0]), ('normal control', {'lines': [-853, 290, -24798, 884, 175], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 4}, 'idx': 4}, [1349, 0, 25651]), ('normal control', {'lines': [32333, 548], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'once', 'months': 6}, 'idx': 4}, [0, 32881, 0])], [('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('partial-repair probe', {'lines': [428, 16839], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [8634, 8633, 0]), ('partial-repair probe', {'lines': [39079, -13913, -17944, 185], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [19633, 0, 12226]), ('normal control', {'lines': [-22069, 164, -11294], 'coupon': {'type': 'amount', 'value': 58439, 'duration': 'forever', 'months': 2}, 'idx': 2}, [164, 0, 33363]), ('normal control', {'lines': [-26650, 28854], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'forever', 'months': 2}, 'idx': 0}, [14427, 0, 12223]), ('normal control', {'lines': [-25035, 26303, 827, 225, -682], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 3}, 'idx': 7}, [2000, 0, 362]), ('normal control', {'lines': [76, 28807], 'coupon': {'type': 'amount', 'value': 12832, 'duration': 'once', 'months': 3}, 'idx': 7}, [0, 28883, 0])], [('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('partial-repair probe', {'lines': [223, 539], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [762, 0, 0]), ('partial-repair probe', {'lines': [75, 48724, 35794, -7691, 47121], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [131714, 0, 7691]), ('normal control', {'lines': [48674], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 4}, 'idx': 6}, [0, 48674, 0]), ('normal control', {'lines': [68], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 2}, 'idx': 2}, [0, 68, 0]), ('normal control', {'lines': [41248], 'coupon': {'type': 'percent', 'value': 10, 'duration': 'forever', 'months': 3}, 'idx': 3}, [4125, 37123, 0]), ('normal control', {'lines': [-27355, 25927], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 5}, 'idx': 7}, [10000, 0, 11428])], [('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('regression', {'lines': [43771, -19469], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 2}, 'idx': 2}, [0, 24302, 0]), ('partial-repair probe', {'lines': [-19858, 37242], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [500, 16884, 0]), ('partial-repair probe', {'lines': [46847, 18213, 870, 31525], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [32160, 65295, 0]), ('normal control', {'lines': [6838, 478, -23009], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'once', 'months': 1}, 'idx': 1}, [0, 0, 15693]), ('normal control', {'lines': [30400, 75, 28300, 48], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 3}, 'idx': 6}, [10000, 48823, 0]), ('normal control', {'lines': [-4637], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 2}, 'idx': 7}, [0, 0, 4637]), ('normal control', {'lines': [-17023, -29453, -12819, -17510], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 3}, 'idx': 2}, [0, 0, 76805])]]
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 fixtureActualExpectedOutcome
regression 0[119, 672, 0][0, 791, 0]Failed
regression 1[23984, 0, 13203][0, 10781, 0]Failed
partial-repair probe 2[20253, 31689, 0][20253, 31689, 0]Passed
partial-repair probe 3[500, 45914, 0][500, 45914, 0]Passed
normal control 4[0, 0, 9318][0, 0, 9318]Passed
normal control 5[0, 165, 0][0, 165, 0]Passed
normal control 6[2000, 35862, 0][2000, 35862, 0]Passed
normal control 7[0, 0, 51561][0, 0, 51561]Passed

SHA-256 / 912308bf2373e0b82da4072852dd090b98d9f1c27f7e71584b08a37362d75029

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    c = x['coupon']
    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] < c['months'] - 1)
    pos = [a for a in x['lines'] if a > 0]
    discount = 0
    if active:
        if c['type'] == 'percent':
            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)
        else:
            discount = min(c['value'], sum(pos))
    total = sum(x['lines']) - discount
    return [discount, max(0, total), max(0, -total)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'lines': [791], 'coupon': {'type': 'percent', 'value': 15, 'duration': 'repeating', 'months': 1}, 'idx': 1}, [0, 791, 0]), ('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('partial-repair probe', {'lines': [27067, -9430, 18496, 15243, 566], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [20253, 31689, 0]), ('partial-repair probe', {'lines': [463, 18993, 591, 25859, 508], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [500, 45914, 0]), ('normal control', {'lines': [-9318], 'coupon': {'type': 'amount', 'value': 29602, 'duration': 'forever', 'months': 3}, 'idx': 7}, [0, 0, 9318]), ('normal control', {'lines': [165], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'once', 'months': 3}, 'idx': 4}, [0, 165, 0]), ('normal control', {'lines': [32449, 5413], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 4}, [2000, 35862, 0]), ('normal control', {'lines': [-19181, 10683, -19030, -24033], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 1}, 'idx': 5}, [0, 0, 51561])], [('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('partial-repair probe', {'lines': [73], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [24, 49, 0]), ('partial-repair probe', {'lines': [-7260, 406], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [406, 0, 7260]), ('normal control', {'lines': [765], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 1}, [765, 0, 0]), ('normal control', {'lines': [196, 15845, -4816, 575, 15297], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 2}, 'idx': 6}, [2000, 25097, 0]), ('normal control', {'lines': [-853, 290, -24798, 884, 175], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 4}, 'idx': 4}, [1349, 0, 25651]), ('normal control', {'lines': [32333, 548], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'once', 'months': 6}, 'idx': 4}, [0, 32881, 0])], [('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('partial-repair probe', {'lines': [428, 16839], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [8634, 8633, 0]), ('partial-repair probe', {'lines': [39079, -13913, -17944, 185], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [19633, 0, 12226]), ('normal control', {'lines': [-22069, 164, -11294], 'coupon': {'type': 'amount', 'value': 58439, 'duration': 'forever', 'months': 2}, 'idx': 2}, [164, 0, 33363]), ('normal control', {'lines': [-26650, 28854], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'forever', 'months': 2}, 'idx': 0}, [14427, 0, 12223]), ('normal control', {'lines': [-25035, 26303, 827, 225, -682], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 3}, 'idx': 7}, [2000, 0, 362]), ('normal control', {'lines': [76, 28807], 'coupon': {'type': 'amount', 'value': 12832, 'duration': 'once', 'months': 3}, 'idx': 7}, [0, 28883, 0])], [('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('partial-repair probe', {'lines': [223, 539], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [762, 0, 0]), ('partial-repair probe', {'lines': [75, 48724, 35794, -7691, 47121], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [131714, 0, 7691]), ('normal control', {'lines': [48674], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 4}, 'idx': 6}, [0, 48674, 0]), ('normal control', {'lines': [68], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 2}, 'idx': 2}, [0, 68, 0]), ('normal control', {'lines': [41248], 'coupon': {'type': 'percent', 'value': 10, 'duration': 'forever', 'months': 3}, 'idx': 3}, [4125, 37123, 0]), ('normal control', {'lines': [-27355, 25927], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 5}, 'idx': 7}, [10000, 0, 11428])], [('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('regression', {'lines': [43771, -19469], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 2}, 'idx': 2}, [0, 24302, 0]), ('partial-repair probe', {'lines': [-19858, 37242], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [500, 16884, 0]), ('partial-repair probe', {'lines': [46847, 18213, 870, 31525], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [32160, 65295, 0]), ('normal control', {'lines': [6838, 478, -23009], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'once', 'months': 1}, 'idx': 1}, [0, 0, 15693]), ('normal control', {'lines': [30400, 75, 28300, 48], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 3}, 'idx': 6}, [10000, 48823, 0]), ('normal control', {'lines': [-4637], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 2}, 'idx': 7}, [0, 0, 4637]), ('normal control', {'lines': [-17023, -29453, -12819, -17510], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 3}, 'idx': 2}, [0, 0, 76805])]]
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 fixtureActualExpectedOutcome
regression 0[0, 791, 0][0, 791, 0]Passed
regression 1[0, 10781, 0][0, 10781, 0]Passed
partial-repair probe 2[0, 51942, 0][20253, 31689, 0]Failed
partial-repair probe 3[0, 46414, 0][500, 45914, 0]Failed
normal control 4[0, 0, 9318][0, 0, 9318]Passed
normal control 5[0, 165, 0][0, 165, 0]Passed
normal control 6[2000, 35862, 0][2000, 35862, 0]Passed
normal control 7[0, 0, 51561][0, 0, 51561]Passed

SHA-256 / 9af56fda0e6ae1b949a134e36ee95b3efe469b77ee3cdf7b7cbc3a18ce8c36dd

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    c = x['coupon']
    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] < c['months'])
    pos = [a for a in x['lines'] if a > 0]
    discount = 0
    if active:
        if c['type'] == 'percent':
            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)
        else:
            discount = min(c['value'], sum(pos))
    total = sum(x['lines']) - discount
    return [discount, max(0, total), max(0, -total)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'lines': [791], 'coupon': {'type': 'percent', 'value': 15, 'duration': 'repeating', 'months': 1}, 'idx': 1}, [0, 791, 0]), ('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('partial-repair probe', {'lines': [27067, -9430, 18496, 15243, 566], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [20253, 31689, 0]), ('partial-repair probe', {'lines': [463, 18993, 591, 25859, 508], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [500, 45914, 0]), ('normal control', {'lines': [-9318], 'coupon': {'type': 'amount', 'value': 29602, 'duration': 'forever', 'months': 3}, 'idx': 7}, [0, 0, 9318]), ('normal control', {'lines': [165], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'once', 'months': 3}, 'idx': 4}, [0, 165, 0]), ('normal control', {'lines': [32449, 5413], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 4}, [2000, 35862, 0]), ('normal control', {'lines': [-19181, 10683, -19030, -24033], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 1}, 'idx': 5}, [0, 0, 51561])], [('regression', {'lines': [-8928, 16007, 36, 31923, -28257], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 10781, 0]), ('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('partial-repair probe', {'lines': [73], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 4}, 'idx': 3}, [24, 49, 0]), ('partial-repair probe', {'lines': [-7260, 406], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [406, 0, 7260]), ('normal control', {'lines': [765], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 1}, [765, 0, 0]), ('normal control', {'lines': [196, 15845, -4816, 575, 15297], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 2}, 'idx': 6}, [2000, 25097, 0]), ('normal control', {'lines': [-853, 290, -24798, 884, 175], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 4}, 'idx': 4}, [1349, 0, 25651]), ('normal control', {'lines': [32333, 548], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'once', 'months': 6}, 'idx': 4}, [0, 32881, 0])], [('regression', {'lines': [17999, -28473, 22583, -24360, -11962], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 3}, 'idx': 3}, [0, 0, 24213]), ('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('partial-repair probe', {'lines': [428, 16839], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [8634, 8633, 0]), ('partial-repair probe', {'lines': [39079, -13913, -17944, 185], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [19633, 0, 12226]), ('normal control', {'lines': [-22069, 164, -11294], 'coupon': {'type': 'amount', 'value': 58439, 'duration': 'forever', 'months': 2}, 'idx': 2}, [164, 0, 33363]), ('normal control', {'lines': [-26650, 28854], 'coupon': {'type': 'percent', 'value': 50, 'duration': 'forever', 'months': 2}, 'idx': 0}, [14427, 0, 12223]), ('normal control', {'lines': [-25035, 26303, 827, 225, -682], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'forever', 'months': 3}, 'idx': 7}, [2000, 0, 362]), ('normal control', {'lines': [76, 28807], 'coupon': {'type': 'amount', 'value': 12832, 'duration': 'once', 'months': 3}, 'idx': 7}, [0, 28883, 0])], [('regression', {'lines': [-25864, 995, 19540], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 0, 5329]), ('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('partial-repair probe', {'lines': [223, 539], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [762, 0, 0]), ('partial-repair probe', {'lines': [75, 48724, 35794, -7691, 47121], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 6}, 'idx': 5}, [131714, 0, 7691]), ('normal control', {'lines': [48674], 'coupon': {'type': 'percent', 'value': 25, 'duration': 'repeating', 'months': 4}, 'idx': 6}, [0, 48674, 0]), ('normal control', {'lines': [68], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 2}, 'idx': 2}, [0, 68, 0]), ('normal control', {'lines': [41248], 'coupon': {'type': 'percent', 'value': 10, 'duration': 'forever', 'months': 3}, 'idx': 3}, [4125, 37123, 0]), ('normal control', {'lines': [-27355, 25927], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 5}, 'idx': 7}, [10000, 0, 11428])], [('regression', {'lines': [817, 2411], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 6}, 'idx': 6}, [0, 3228, 0]), ('regression', {'lines': [43771, -19469], 'coupon': {'type': 'amount', 'value': 2000, 'duration': 'repeating', 'months': 2}, 'idx': 2}, [0, 24302, 0]), ('partial-repair probe', {'lines': [-19858, 37242], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'repeating', 'months': 1}, 'idx': 0}, [500, 16884, 0]), ('partial-repair probe', {'lines': [46847, 18213, 870, 31525], 'coupon': {'type': 'percent', 'value': 33, 'duration': 'repeating', 'months': 3}, 'idx': 2}, [32160, 65295, 0]), ('normal control', {'lines': [6838, 478, -23009], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'once', 'months': 1}, 'idx': 1}, [0, 0, 15693]), ('normal control', {'lines': [30400, 75, 28300, 48], 'coupon': {'type': 'amount', 'value': 10000, 'duration': 'forever', 'months': 3}, 'idx': 6}, [10000, 48823, 0]), ('normal control', {'lines': [-4637], 'coupon': {'type': 'percent', 'value': 100, 'duration': 'repeating', 'months': 2}, 'idx': 7}, [0, 0, 4637]), ('normal control', {'lines': [-17023, -29453, -12819, -17510], 'coupon': {'type': 'amount', 'value': 500, 'duration': 'once', 'months': 3}, 'idx': 2}, [0, 0, 76805])]]
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 fixtureActualExpectedOutcome
regression 0[0, 791, 0][0, 791, 0]Passed
regression 1[0, 10781, 0][0, 10781, 0]Passed
partial-repair probe 2[20253, 31689, 0][20253, 31689, 0]Passed
partial-repair probe 3[500, 45914, 0][500, 45914, 0]Passed
normal control 4[0, 0, 9318][0, 0, 9318]Passed
normal control 5[0, 165, 0][0, 165, 0]Passed
normal control 6[2000, 35862, 0][2000, 35862, 0]Passed
normal control 7[0, 0, 51561][0, 0, 51561]Passed

SHA-256 / dbaa02a4dc28bc63a30be8b92e135dbf45040f17a4d451698dd4e74a02e9ed06

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:36.293492+00:00.

Case digest / 42d135cf74aadf0171adad13cf6b1f342db46fc05d4545ecee1fb3cf6d91fde4