{"abstract":"A three-month coupon discounts a fourth invoice.","category":"Subscription proration billing","checks":8,"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)].","evaluation_group":"w2-subscription-proration-coupon-on-prorated-invoice","failed_approach":"The attempt ends the coupon one invoice early.","family":"w2-subscription-proration-coupon-on-prorated-invoice-repeating-coupon-window","id":"FA-59436","implementations":{"attempt":{"sha256":"9af56fda0e6ae1b949a134e36ee95b3efe469b77ee3cdf7b7cbc3a18ce8c36dd","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x['coupon']\n    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] < c['months'] - 1)\n    pos = [a for a in x['lines'] if a > 0]\n    discount = 0\n    if active:\n        if c['type'] == 'percent':\n            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)\n        else:\n            discount = min(c['value'], sum(pos))\n    total = sum(x['lines']) - discount\n    return [discount, max(0, total), max(0, -total)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"912308bf2373e0b82da4072852dd090b98d9f1c27f7e71584b08a37362d75029","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x['coupon']\n    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] <= c['months'])\n    pos = [a for a in x['lines'] if a > 0]\n    discount = 0\n    if active:\n        if c['type'] == 'percent':\n            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)\n        else:\n            discount = min(c['value'], sum(pos))\n    total = sum(x['lines']) - discount\n    return [discount, max(0, total), max(0, -total)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"dbaa02a4dc28bc63a30be8b92e135dbf45040f17a4d451698dd4e74a02e9ed06","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    c = x['coupon']\n    active = c['duration'] == 'forever' or (c['duration'] == 'once' and x['idx'] == 0) or (c['duration'] == 'repeating' and x['idx'] < c['months'])\n    pos = [a for a in x['lines'] if a > 0]\n    discount = 0\n    if active:\n        if c['type'] == 'percent':\n            discount = sum((a * c['value'] * 2 + 100) // 200 for a in pos)\n        else:\n            discount = min(c['value'], sum(pos))\n    total = sum(x['lines']) - discount\n    return [discount, max(0, total), max(0, -total)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('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])]]\nfor i, (label, args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (label, i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-subscription-proration-coupon-on-prorated-invoice-repeating-coupon-window","generated_at":"2026-09-29T14:46:36.293492+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Coupons interact with proration credits; discounting a credit line or over-applying an amount-off coupon changes what customers pay.","repair":"Restore the contract rule at the repeating coupon window step: use `x['idx'] < c['months']`.","root_cause":"The repeating duration test is inclusive of the month count.","sha256":"42d135cf74aadf0171adad13cf6b1f342db46fc05d4545ecee1fb3cf6d91fde4","title":"Coupons on invoices with proration lines: repeating coupon window · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":47.31,"exit_code":1,"observations":[{"actual":[0,791,0],"check":"regression 0","expected":[0,791,0],"passed":true},{"actual":[0,10781,0],"check":"regression 1","expected":[0,10781,0],"passed":true},{"actual":[0,51942,0],"check":"partial-repair probe 2","expected":[20253,31689,0],"passed":false},{"actual":[0,46414,0],"check":"partial-repair probe 3","expected":[500,45914,0],"passed":false},{"actual":[0,0,9318],"check":"normal control 4","expected":[0,0,9318],"passed":true},{"actual":[0,165,0],"check":"normal control 5","expected":[0,165,0],"passed":true},{"actual":[2000,35862,0],"check":"normal control 6","expected":[2000,35862,0],"passed":true},{"actual":[0,0,51561],"check":"normal control 7","expected":[0,0,51561],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 791, 0], \"expected\": [0, 791, 0], \"passed\": true}, {\"check\": \"regression 1\", \"actual\": [0, 10781, 0], \"expected\": [0, 10781, 0], \"passed\": true}, {\"check\": \"partial-repair probe 2\", \"actual\": [0, 51942, 0], \"expected\": [20253, 31689, 0], \"passed\": false}, {\"check\": \"partial-repair probe 3\", \"actual\": [0, 46414, 0], \"expected\": [500, 45914, 0], \"passed\": false}, {\"check\": \"normal control 4\", \"actual\": [0, 0, 9318], \"expected\": [0, 0, 9318], \"passed\": true}, {\"check\": \"normal control 5\", \"actual\": [0, 165, 0], \"expected\": [0, 165, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [2000, 35862, 0], \"expected\": [2000, 35862, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [0, 0, 51561], \"expected\": [0, 0, 51561], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":45.832,"exit_code":1,"observations":[{"actual":[119,672,0],"check":"regression 0","expected":[0,791,0],"passed":false},{"actual":[23984,0,13203],"check":"regression 1","expected":[0,10781,0],"passed":false},{"actual":[20253,31689,0],"check":"partial-repair probe 2","expected":[20253,31689,0],"passed":true},{"actual":[500,45914,0],"check":"partial-repair probe 3","expected":[500,45914,0],"passed":true},{"actual":[0,0,9318],"check":"normal control 4","expected":[0,0,9318],"passed":true},{"actual":[0,165,0],"check":"normal control 5","expected":[0,165,0],"passed":true},{"actual":[2000,35862,0],"check":"normal control 6","expected":[2000,35862,0],"passed":true},{"actual":[0,0,51561],"check":"normal control 7","expected":[0,0,51561],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [119, 672, 0], \"expected\": [0, 791, 0], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [23984, 0, 13203], \"expected\": [0, 10781, 0], \"passed\": false}, {\"check\": \"partial-repair probe 2\", \"actual\": [20253, 31689, 0], \"expected\": [20253, 31689, 0], \"passed\": true}, {\"check\": \"partial-repair probe 3\", \"actual\": [500, 45914, 0], \"expected\": [500, 45914, 0], \"passed\": true}, {\"check\": \"normal control 4\", \"actual\": [0, 0, 9318], \"expected\": [0, 0, 9318], \"passed\": true}, {\"check\": \"normal control 5\", \"actual\": [0, 165, 0], \"expected\": [0, 165, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [2000, 35862, 0], \"expected\": [2000, 35862, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [0, 0, 51561], \"expected\": [0, 0, 51561], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.654,"exit_code":0,"observations":[{"actual":[0,791,0],"check":"regression 0","expected":[0,791,0],"passed":true},{"actual":[0,10781,0],"check":"regression 1","expected":[0,10781,0],"passed":true},{"actual":[20253,31689,0],"check":"partial-repair probe 2","expected":[20253,31689,0],"passed":true},{"actual":[500,45914,0],"check":"partial-repair probe 3","expected":[500,45914,0],"passed":true},{"actual":[0,0,9318],"check":"normal control 4","expected":[0,0,9318],"passed":true},{"actual":[0,165,0],"check":"normal control 5","expected":[0,165,0],"passed":true},{"actual":[2000,35862,0],"check":"normal control 6","expected":[2000,35862,0],"passed":true},{"actual":[0,0,51561],"check":"normal control 7","expected":[0,0,51561],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 791, 0], \"expected\": [0, 791, 0], \"passed\": true}, {\"check\": \"regression 1\", \"actual\": [0, 10781, 0], \"expected\": [0, 10781, 0], \"passed\": true}, {\"check\": \"partial-repair probe 2\", \"actual\": [20253, 31689, 0], \"expected\": [20253, 31689, 0], \"passed\": true}, {\"check\": \"partial-repair probe 3\", \"actual\": [500, 45914, 0], \"expected\": [500, 45914, 0], \"passed\": true}, {\"check\": \"normal control 4\", \"actual\": [0, 0, 9318], \"expected\": [0, 0, 9318], \"passed\": true}, {\"check\": \"normal control 5\", \"actual\": [0, 165, 0], \"expected\": [0, 165, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [2000, 35862, 0], \"expected\": [2000, 35862, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [0, 0, 51561], \"expected\": [0, 0, 51561], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}