{"abstract":"Credits are consumed on their expiry day.","category":"Subscription proration billing","checks":8,"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]].","contract_signature":"x","evaluation_group":"w2-subscription-proration-expiring-credit-grants","failed_approach":"The attempt fixes expiry but excludes credits on the day they are granted.","family":"w2-subscription-proration-expiring-credit-grants-expiry-boundary","id":"FA-59756","implementations":{"attempt":{"sha256":"37ddfd5d4633a3076107292e8a7aa6e22cbc6faa8fa6a89ad66d23c8d9a195e9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    usable = [g for g in x['grants'] if g[2] < x['day'] < g[1]]\n    usable.sort(key=lambda g: (g[1], g[2]))\n    need = x['amount']\n    applied = 0\n    rest = []\n    for amt, exp, gd in usable:\n        take = min(amt, need)\n        need -= take\n        applied += take\n        if amt - take > 0:\n            rest.append([amt - take, exp])\n    return [applied, need, rest]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('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]]]), ('partial-repair probe', {'grants': [[1468, 59, 37], [2753, 34, 1], [3215, 49, 24]], 'day': 24, 'amount': 9315}, [5968, 3347, []]), ('partial-repair probe', {'grants': [[2342, 62, 27], [2349, 64, 11], [3400, 5, 3], [4319, 29, 10]], 'day': 3, 'amount': 11699}, [3400, 8299, []]), ('normal control', {'grants': [[4886, 68, 27]], 'day': 34, 'amount': 6459}, [4886, 1573, []]), ('normal control', {'grants': [[1532, 36, 16], [3167, 81, 23]], 'day': 79, 'amount': 9179}, [3167, 6012, []]), ('normal control', {'grants': [], 'day': 33, 'amount': 11076}, [0, 11076, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 6225}, [0, 6225, []])], [('regression', {'grants': [[2668, 55, 8], [2725, 31, 4], [4115, 33, 21], [2183, 76, 33], [1337, 34, 20]], 'day': 33, 'amount': 8329}, [6188, 2141, []]), ('regression', {'grants': [[2784, 49, 29], [4250, 5, 2]], 'day': 5, 'amount': 6418}, [0, 6418, []]), ('partial-repair probe', {'grants': [[2773, 15, 9], [1310, 48, 23], [4052, 71, 20]], 'day': 23, 'amount': 8492}, [5362, 3130, []]), ('partial-repair probe', {'grants': [[1384, 70, 15], [4042, 35, 28], [3777, 37, 32], [3126, 48, 5]], 'day': 28, 'amount': 10480}, [8552, 1928, []]), ('normal control', {'grants': [[1988, 63, 35]], 'day': 58, 'amount': 4262}, [1988, 2274, []]), ('normal control', {'grants': [], 'day': 80, 'amount': 1837}, [0, 1837, []]), ('normal control', {'grants': [], 'day': 25, 'amount': 2572}, [0, 2572, []]), ('normal control', {'grants': [], 'day': 73, 'amount': 5894}, [0, 5894, []])], [('regression', {'grants': [[2895, 67, 19], [4978, 53, 27], [2653, 9, 6], [1320, 27, 4]], 'day': 27, 'amount': 4318}, [4318, 0, [[660, 53], [2895, 67]]]), ('regression', {'grants': [[2817, 40, 9], [519, 18, 4], [2025, 35, 27]], 'day': 18, 'amount': 2988}, [2817, 171, []]), ('partial-repair probe', {'grants': [[348, 44, 22], [3151, 71, 29], [1829, 75, 25]], 'day': 22, 'amount': 1836}, [348, 1488, []]), ('partial-repair probe', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('normal control', {'grants': [], 'day': 37, 'amount': 8374}, [0, 8374, []]), ('normal control', {'grants': [[4177, 56, 38]], 'day': 71, 'amount': 3542}, [0, 3542, []]), ('normal control', {'grants': [[376, 42, 8], [1615, 72, 38], [623, 54, 28]], 'day': 65, 'amount': 9857}, [1615, 8242, []]), ('normal control', {'grants': [[238, 31, 27], [141, 56, 8], [1146, 21, 2]], 'day': 74, 'amount': 3146}, [0, 3146, []])], [('regression', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('regression', {'grants': [[4933, 63, 40]], 'day': 63, 'amount': 7306}, [0, 7306, []]), ('partial-repair probe', {'grants': [[1288, 33, 20]], 'day': 20, 'amount': 7312}, [1288, 6024, []]), ('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': [[3966, 51, 34], [2127, 27, 16]], 'day': 11, 'amount': 5692}, [0, 5692, []]), ('normal control', {'grants': [[2662, 90, 32], [1143, 59, 19]], 'day': 16, 'amount': 4884}, [0, 4884, []]), ('normal control', {'grants': [], 'day': 8, 'amount': 6670}, [0, 6670, []]), ('normal control', {'grants': [], 'day': 4, 'amount': 7075}, [0, 7075, []])], [('regression', {'grants': [[2668, 55, 8], [2725, 31, 4], [4115, 33, 21], [2183, 76, 33], [1337, 34, 20]], 'day': 33, 'amount': 8329}, [6188, 2141, []]), ('regression', {'grants': [[4428, 38, 34], [4352, 38, 5], [1603, 11, 10]], 'day': 38, 'amount': 11185}, [0, 11185, []]), ('partial-repair probe', {'grants': [[1025, 32, 22], [4283, 39, 31], [3756, 69, 37], [2137, 3, 0], [2949, 17, 3]], 'day': 22, 'amount': 2736}, [1025, 1711, []]), ('partial-repair probe', {'grants': [[4347, 76, 18], [935, 10, 2], [3052, 14, 3], [1029, 83, 33], [982, 49, 22]], 'day': 22, 'amount': 8855}, [5329, 3526, []]), ('normal control', {'grants': [], 'day': 42, 'amount': 6987}, [0, 6987, []]), ('normal control', {'grants': [], 'day': 46, 'amount': 9267}, [0, 9267, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 9420}, [0, 9420, []]), ('normal control', {'grants': [], 'day': 35, 'amount': 11680}, [0, 11680, []])]]\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":"1dc83770d4b7348765492bd918d796e226c75677934ff9b4c75b8b578604930d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    usable = [g for g in x['grants'] if g[2] <= x['day'] <= g[1]]\n    usable.sort(key=lambda g: (g[1], g[2]))\n    need = x['amount']\n    applied = 0\n    rest = []\n    for amt, exp, gd in usable:\n        take = min(amt, need)\n        need -= take\n        applied += take\n        if amt - take > 0:\n            rest.append([amt - take, exp])\n    return [applied, need, rest]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('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]]]), ('partial-repair probe', {'grants': [[1468, 59, 37], [2753, 34, 1], [3215, 49, 24]], 'day': 24, 'amount': 9315}, [5968, 3347, []]), ('partial-repair probe', {'grants': [[2342, 62, 27], [2349, 64, 11], [3400, 5, 3], [4319, 29, 10]], 'day': 3, 'amount': 11699}, [3400, 8299, []]), ('normal control', {'grants': [[4886, 68, 27]], 'day': 34, 'amount': 6459}, [4886, 1573, []]), ('normal control', {'grants': [[1532, 36, 16], [3167, 81, 23]], 'day': 79, 'amount': 9179}, [3167, 6012, []]), ('normal control', {'grants': [], 'day': 33, 'amount': 11076}, [0, 11076, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 6225}, [0, 6225, []])], [('regression', {'grants': [[2668, 55, 8], [2725, 31, 4], [4115, 33, 21], [2183, 76, 33], [1337, 34, 20]], 'day': 33, 'amount': 8329}, [6188, 2141, []]), ('regression', {'grants': [[2784, 49, 29], [4250, 5, 2]], 'day': 5, 'amount': 6418}, [0, 6418, []]), ('partial-repair probe', {'grants': [[2773, 15, 9], [1310, 48, 23], [4052, 71, 20]], 'day': 23, 'amount': 8492}, [5362, 3130, []]), ('partial-repair probe', {'grants': [[1384, 70, 15], [4042, 35, 28], [3777, 37, 32], [3126, 48, 5]], 'day': 28, 'amount': 10480}, [8552, 1928, []]), ('normal control', {'grants': [[1988, 63, 35]], 'day': 58, 'amount': 4262}, [1988, 2274, []]), ('normal control', {'grants': [], 'day': 80, 'amount': 1837}, [0, 1837, []]), ('normal control', {'grants': [], 'day': 25, 'amount': 2572}, [0, 2572, []]), ('normal control', {'grants': [], 'day': 73, 'amount': 5894}, [0, 5894, []])], [('regression', {'grants': [[2895, 67, 19], [4978, 53, 27], [2653, 9, 6], [1320, 27, 4]], 'day': 27, 'amount': 4318}, [4318, 0, [[660, 53], [2895, 67]]]), ('regression', {'grants': [[2817, 40, 9], [519, 18, 4], [2025, 35, 27]], 'day': 18, 'amount': 2988}, [2817, 171, []]), ('partial-repair probe', {'grants': [[348, 44, 22], [3151, 71, 29], [1829, 75, 25]], 'day': 22, 'amount': 1836}, [348, 1488, []]), ('partial-repair probe', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('normal control', {'grants': [], 'day': 37, 'amount': 8374}, [0, 8374, []]), ('normal control', {'grants': [[4177, 56, 38]], 'day': 71, 'amount': 3542}, [0, 3542, []]), ('normal control', {'grants': [[376, 42, 8], [1615, 72, 38], [623, 54, 28]], 'day': 65, 'amount': 9857}, [1615, 8242, []]), ('normal control', {'grants': [[238, 31, 27], [141, 56, 8], [1146, 21, 2]], 'day': 74, 'amount': 3146}, [0, 3146, []])], [('regression', {'grants': [[3257, 40, 31], [4520, 73, 40], [4293, 11, 10]], 'day': 40, 'amount': 1147}, [1147, 0, [[3373, 73]]]), ('regression', {'grants': [[4933, 63, 40]], 'day': 63, 'amount': 7306}, [0, 7306, []]), ('partial-repair probe', {'grants': [[1288, 33, 20]], 'day': 20, 'amount': 7312}, [1288, 6024, []]), ('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': [[3966, 51, 34], [2127, 27, 16]], 'day': 11, 'amount': 5692}, [0, 5692, []]), ('normal control', {'grants': [[2662, 90, 32], [1143, 59, 19]], 'day': 16, 'amount': 4884}, [0, 4884, []]), ('normal control', {'grants': [], 'day': 8, 'amount': 6670}, [0, 6670, []]), ('normal control', {'grants': [], 'day': 4, 'amount': 7075}, [0, 7075, []])], [('regression', {'grants': [[2668, 55, 8], [2725, 31, 4], [4115, 33, 21], [2183, 76, 33], [1337, 34, 20]], 'day': 33, 'amount': 8329}, [6188, 2141, []]), ('regression', {'grants': [[4428, 38, 34], [4352, 38, 5], [1603, 11, 10]], 'day': 38, 'amount': 11185}, [0, 11185, []]), ('partial-repair probe', {'grants': [[1025, 32, 22], [4283, 39, 31], [3756, 69, 37], [2137, 3, 0], [2949, 17, 3]], 'day': 22, 'amount': 2736}, [1025, 1711, []]), ('partial-repair probe', {'grants': [[4347, 76, 18], [935, 10, 2], [3052, 14, 3], [1029, 83, 33], [982, 49, 22]], 'day': 22, 'amount': 8855}, [5329, 3526, []]), ('normal control', {'grants': [], 'day': 42, 'amount': 6987}, [0, 6987, []]), ('normal control', {'grants': [], 'day': 46, 'amount': 9267}, [0, 9267, []]), ('normal control', {'grants': [], 'day': 50, 'amount': 9420}, [0, 9420, []]), ('normal control', {'grants': [], 'day': 35, 'amount': 11680}, [0, 11680, []])]]\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-expiring-credit-grants-expiry-boundary","generated_at":"2026-09-29T14:46:39.304818+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Promotional credits must be burned in expiry order and never after they expire.","root_cause":"The expiry comparison is inclusive.","sha256":"961bda091c6106f424c416df69ca1488fc628448bdb8ed136dea31ea8977108b","title":"Expiring credit grants applied to invoices: expiry boundary · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":41.954,"exit_code":1,"observations":[{"actual":[0,1147,[]],"check":"regression 0","expected":[1147,0,[[3373,73]]],"passed":false},{"actual":[5792,0,[[280,68]]],"check":"regression 1","expected":[5792,0,[[280,68]]],"passed":true},{"actual":[2753,6562,[]],"check":"partial-repair probe 2","expected":[5968,3347,[]],"passed":false},{"actual":[0,11699,[]],"check":"partial-repair probe 3","expected":[3400,8299,[]],"passed":false},{"actual":[4886,1573,[]],"check":"normal control 4","expected":[4886,1573,[]],"passed":true},{"actual":[3167,6012,[]],"check":"normal control 5","expected":[3167,6012,[]],"passed":true},{"actual":[0,11076,[]],"check":"normal control 6","expected":[0,11076,[]],"passed":true},{"actual":[0,6225,[]],"check":"normal control 7","expected":[0,6225,[]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [0, 1147, []], \"expected\": [1147, 0, [[3373, 73]]], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [5792, 0, [[280, 68]]], \"expected\": [5792, 0, [[280, 68]]], \"passed\": true}, {\"check\": \"partial-repair probe 2\", \"actual\": [2753, 6562, []], \"expected\": [5968, 3347, []], \"passed\": false}, {\"check\": \"partial-repair probe 3\", \"actual\": [0, 11699, []], \"expected\": [3400, 8299, []], \"passed\": false}, {\"check\": \"normal control 4\", \"actual\": [4886, 1573, []], \"expected\": [4886, 1573, []], \"passed\": true}, {\"check\": \"normal control 5\", \"actual\": [3167, 6012, []], \"expected\": [3167, 6012, []], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [0, 11076, []], \"expected\": [0, 11076, []], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [0, 6225, []], \"expected\": [0, 6225, []], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.772,"exit_code":1,"observations":[{"actual":[1147,0,[[2110,40],[4520,73]]],"check":"regression 0","expected":[1147,0,[[3373,73]]],"passed":false},{"actual":[5792,0,[[2995,68]]],"check":"regression 1","expected":[5792,0,[[280,68]]],"passed":false},{"actual":[5968,3347,[]],"check":"partial-repair probe 2","expected":[5968,3347,[]],"passed":true},{"actual":[3400,8299,[]],"check":"partial-repair probe 3","expected":[3400,8299,[]],"passed":true},{"actual":[4886,1573,[]],"check":"normal control 4","expected":[4886,1573,[]],"passed":true},{"actual":[3167,6012,[]],"check":"normal control 5","expected":[3167,6012,[]],"passed":true},{"actual":[0,11076,[]],"check":"normal control 6","expected":[0,11076,[]],"passed":true},{"actual":[0,6225,[]],"check":"normal control 7","expected":[0,6225,[]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression 0\", \"actual\": [1147, 0, [[2110, 40], [4520, 73]]], \"expected\": [1147, 0, [[3373, 73]]], \"passed\": false}, {\"check\": \"regression 1\", \"actual\": [5792, 0, [[2995, 68]]], \"expected\": [5792, 0, [[280, 68]]], \"passed\": false}, {\"check\": \"partial-repair probe 2\", \"actual\": [5968, 3347, []], \"expected\": [5968, 3347, []], \"passed\": true}, {\"check\": \"partial-repair probe 3\", \"actual\": [3400, 8299, []], \"expected\": [3400, 8299, []], \"passed\": true}, {\"check\": \"normal control 4\", \"actual\": [4886, 1573, []], \"expected\": [4886, 1573, []], \"passed\": true}, {\"check\": \"normal control 5\", \"actual\": [3167, 6012, []], \"expected\": [3167, 6012, []], \"passed\": true}, {\"check\": \"normal control 6\", \"actual\": [0, 11076, []], \"expected\": [0, 11076, []], \"passed\": true}, {\"check\": \"normal control 7\", \"actual\": [0, 6225, []], \"expected\": [0, 6225, []], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}