{"abstract":"Customers with large balances see negative amounts due and a drained balance.","category":"Subscription proration billing","checks":10,"contract":"Input {total, credit_notes, balance, min_payment}. Credit notes apply first, capped at the total; any excess credit-note value joins the customer balance. The balance then applies up to the remaining due. A remaining due above 0 but below min_payment is carried to the next invoice instead of charged. Return [due, balance_after, carried].","evaluation_group":"w2-subscription-proration-credit-balance-application","failed_approach":"The attempt caps by the original total, ignoring the credit notes already applied.","family":"w2-subscription-proration-credit-balance-application-balance-application-cap","id":"FA-59566","implementations":{"attempt":{"sha256":"587200e9f48cb2261d092ff9940a3437ce92029b0fd12c091013bbd06c5c99e4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance'] + (cn - use_cn)\n    use_bal = min(bal, x['total'])\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0])]]\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":"afd35b13830f150a30aacd6d67816eef2912aa7691e74adafe4abc404d50b8f5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance'] + (cn - use_cn)\n    use_bal = bal\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0])]]\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":"6c63b4f2c21186e752de3fc9f85fcf68f4af19a0e44ed6c0e00eda65026ea2da","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    due = x['total']\n    cn = sum(x['credit_notes'])\n    use_cn = min(cn, due)\n    due -= use_cn\n    bal = x['balance'] + (cn - use_cn)\n    use_bal = min(bal, due)\n    due -= use_bal\n    bal -= use_bal\n    carried = 0\n    if 0 < due < x['min_payment']:\n        carried = due\n        due = 0\n    return [due, bal, carried]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('normal control', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('normal control', {'total': 27004, 'credit_notes': [11844, 8578], 'balance': 0, 'min_payment': 0}, [6582, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0]), ('normal control', {'total': 32368, 'credit_notes': [17289, 13095], 'balance': 0, 'min_payment': 0}, [1984, 0, 0]), ('normal control', {'total': 36798, 'credit_notes': [1788], 'balance': 11576, 'min_payment': 50}, [23434, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 34021, 'credit_notes': [12282], 'balance': 0, 'min_payment': 100}, [21739, 0, 0]), ('normal control', {'total': 14007, 'credit_notes': [8643], 'balance': 0, 'min_payment': 50}, [5364, 0, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 9414, 'credit_notes': [5208], 'balance': 5543, 'min_payment': 50}, [0, 1337, 0]), ('boundary control', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 43066, 'credit_notes': [366, 14060, 1522], 'balance': 2601, 'min_payment': 100}, [24517, 0, 0]), ('normal control', {'total': 38060, 'credit_notes': [14975, 2846], 'balance': 13326, 'min_payment': 50}, [6913, 0, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0])], [('regression', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 14659, 'credit_notes': [16457, 12670], 'balance': 0, 'min_payment': 50}, [0, 14468, 0]), ('partial-repair probe', {'total': 62, 'credit_notes': [3609], 'balance': 0, 'min_payment': 0}, [0, 3547, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0]), ('normal control', {'total': 48418, 'credit_notes': [6075], 'balance': 0, 'min_payment': 100}, [42343, 0, 0]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0])]]\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-credit-balance-application-balance-application-cap","generated_at":"2026-09-29T14:46:37.527013+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Proration credits land as credit notes and balances whose application order determines the charge.","repair":"Restore the contract rule at the balance application cap step: use `use_bal = min(bal, due)`.","root_cause":"The balance is applied in full without capping at the remaining due.","sha256":"57814293e8b06341b5191b38a144486df15684785ad12557c841fb1b8f287234","title":"Credit notes and customer balance on an invoice: balance application cap · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.595,"exit_code":1,"observations":[{"actual":[-53,2196,0],"check":"regression 0","expected":[0,2249,0],"passed":false},{"actual":[-249,15019,0],"check":"regression 1","expected":[0,15268,0],"passed":false},{"actual":[-299,19368,0],"check":"partial-repair probe 2","expected":[0,19667,0],"passed":false},{"actual":[-7761,27303,0],"check":"partial-repair probe 3","expected":[0,35064,0],"passed":false},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 5","expected":[50,0,0],"passed":true},{"actual":[294,0,0],"check":"normal control 6","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 7","expected":[36738,0,0],"passed":true},{"actual":[27156,0,0],"check":"normal control 8","expected":[27156,0,0],"passed":true},{"actual":[4442,0,0],"check":"normal control 9","expected":[4442,0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [-53, 2196, 0], \"expected\": [0, 2249, 0], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [-249, 15019, 0], \"expected\": [0, 15268, 0], \"passed\": false}, {\"check\": \"partial-repair probe 2\", \"actual\": [-299, 19368, 0], \"expected\": [0, 19667, 0], \"passed\": false}, {\"check\": \"partial-repair probe 3\", \"actual\": [-7761, 27303, 0], \"expected\": [0, 35064, 0], \"passed\": false}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [27156, 0, 0], \"expected\": [27156, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [4442, 0, 0], \"expected\": [4442, 0, 0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.727,"exit_code":1,"observations":[{"actual":[-2249,0,0],"check":"regression 0","expected":[0,2249,0],"passed":false},{"actual":[-15268,0,0],"check":"regression 1","expected":[0,15268,0],"passed":false},{"actual":[-19667,0,0],"check":"partial-repair probe 2","expected":[0,19667,0],"passed":false},{"actual":[-35064,0,0],"check":"partial-repair probe 3","expected":[0,35064,0],"passed":false},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 5","expected":[50,0,0],"passed":true},{"actual":[294,0,0],"check":"normal control 6","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 7","expected":[36738,0,0],"passed":true},{"actual":[27156,0,0],"check":"normal control 8","expected":[27156,0,0],"passed":true},{"actual":[4442,0,0],"check":"normal control 9","expected":[4442,0,0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [-2249, 0, 0], \"expected\": [0, 2249, 0], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [-15268, 0, 0], \"expected\": [0, 15268, 0], \"passed\": false}, {\"check\": \"partial-repair probe 2\", \"actual\": [-19667, 0, 0], \"expected\": [0, 19667, 0], \"passed\": false}, {\"check\": \"partial-repair probe 3\", \"actual\": [-35064, 0, 0], \"expected\": [0, 35064, 0], \"passed\": false}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [27156, 0, 0], \"expected\": [27156, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [4442, 0, 0], \"expected\": [4442, 0, 0], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.11,"exit_code":0,"observations":[{"actual":[0,2249,0],"check":"regression 0","expected":[0,2249,0],"passed":true},{"actual":[0,15268,0],"check":"regression 1","expected":[0,15268,0],"passed":true},{"actual":[0,19667,0],"check":"partial-repair probe 2","expected":[0,19667,0],"passed":true},{"actual":[0,35064,0],"check":"partial-repair probe 3","expected":[0,35064,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 4","expected":[50,0,0],"passed":true},{"actual":[50,0,0],"check":"boundary control 5","expected":[50,0,0],"passed":true},{"actual":[294,0,0],"check":"normal control 6","expected":[294,0,0],"passed":true},{"actual":[36738,0,0],"check":"normal control 7","expected":[36738,0,0],"passed":true},{"actual":[27156,0,0],"check":"normal control 8","expected":[27156,0,0],"passed":true},{"actual":[4442,0,0],"check":"normal control 9","expected":[4442,0,0],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 2249, 0], \"expected\": [0, 2249, 0], \"passed\": true}, {\"check\": \"regression 1\", \"actual\": [0, 15268, 0], \"expected\": [0, 15268, 0], \"passed\": true}, {\"check\": \"partial-repair probe 2\", \"actual\": [0, 19667, 0], \"expected\": [0, 19667, 0], \"passed\": true}, {\"check\": \"partial-repair probe 3\", \"actual\": [0, 35064, 0], \"expected\": [0, 35064, 0], \"passed\": true}, {\"check\": \"boundary control 4\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"boundary control 5\", \"actual\": [50, 0, 0], \"expected\": [50, 0, 0], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [294, 0, 0], \"expected\": [294, 0, 0], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [36738, 0, 0], \"expected\": [36738, 0, 0], \"passed\": true}, {\"check\": \"normal control 8\", \"actual\": [27156, 0, 0], \"expected\": [27156, 0, 0], \"passed\": true}, {\"check\": \"normal control 9\", \"actual\": [4442, 0, 0], \"expected\": [4442, 0, 0], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}