{"abstract":"A tiny xp gain doubles by the entire rested pool.","category":"Game economy crafting balance","checks":8,"contract":"Level L needs 80 + 20*L xp to reach L+1; max level 50. Gains are ignored once level 50 is reached (rested untouched). For each gain g: bonus = min(g, rested) is added on top of g and removed from the rested pool; then as many levels as possible are taken, carrying remaining xp; on reaching level 50 the xp bar is set to 0. Returns [level, xp, rested].","evaluation_group":"w2-game-economy-crafting-balance-rested-xp","failed_approach":"Halving the bonus under-pays the rested doubling.","family":"w2-game-economy-crafting-balance-rested-xp-rested-bonus-size","id":"FA-86311","implementations":{"attempt":{"sha256":"36e56b2dfe47f051544e71f891ed339cd82650253e8c3d1c5abf0d4096116ac9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(level, xp, gains, rested):\n    for g in gains:\n        if level >= 50:\n            break\n        bonus = min(g, rested) // 2\n        rested -= bonus\n        xp += g + bonus\n        while level < 50 and xp >= 80 + 20 * level:\n            xp -= 80 + 20 * level\n            level += 1\n        if level >= 50:\n            xp = 0\n    return [level, xp, rested]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression rested bonus size #1', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('regression rested bonus size #2', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('partial repair boundary #1', [48, 123, [50, 10, 420], 100], [48, 703, 0]),\n  ('partial repair boundary #2', [48, 108, [300, 300, 99, 86, 300], 30], [49, 183, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100])],\n [('regression rested bonus size #1', [1, 130, [300, 99], 1000], [7, 28, 601]),\n  ('regression rested bonus size #2', [5, 106, [10], 1000], [5, 126, 990]),\n  ('regression rested bonus size #3', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('partial repair boundary #1', [1, 37, [100, 100, 2000], 1000], [15, 17, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100]),\n  ('control #2', [5, 79, [300], 0], [6, 199, 0])],\n [('regression rested bonus size #1', [48, 105, [100], 395], [48, 305, 295]),\n  ('regression rested bonus size #2', [1, 132, [10, 100, 99, 100], 1000], [6, 50, 691]),\n  ('partial repair boundary #1', [1, 15, [100], 100], [2, 115, 0]),\n  ('regression rested bonus size #3', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [5, 79, [300], 0], [6, 199, 0]),\n  ('control #2', [10, 7, [300, 50, 99, 100], 0], [11, 276, 0])],\n [('regression rested bonus size #1', [27, 6, [121], 265], [27, 248, 144]),\n  ('regression rested bonus size #2', [5, 80, [300, 99, 50, 99, 300], 1000], [12, 96, 152]),\n  ('partial repair boundary #1', [5, 102, [50, 100], 30], [6, 102, 0]),\n  ('partial repair boundary #2', [5, 92, [179, 50, 437, 100], 155], [9, 173, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('control #1', [5, 79, [100, 10, 2000], 0], [13, 189, 0]),\n  ('control #2', [29, 125, [2000], 0], [32, 85, 0])],\n [('regression rested bonus size #1', [1, 31, [100], 1000], [3, 11, 900]),\n  ('regression rested bonus size #2', [30, 107, [100], 1000], [30, 307, 900]),\n  ('partial repair boundary #1', [1, 19, [50, 2000, 50], 1000], [14, 259, 0]),\n  ('partial repair boundary #2', [30, 136, [2000, 100], 1000], [34, 396, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [30, 122, [50, 10, 300, 50, 100], 0], [30, 632, 0]),\n  ('control #2', [50, 12, [2000, 50, 300, 50], 30], [50, 12, 30])]]\nfor label, args, expected in cases[N-1]:\n    check(label, 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":"39c24b4ff59709b93e1b89ce4745655730964a20bd1bc9e34da65dd9acc02c29","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(level, xp, gains, rested):\n    for g in gains:\n        if level >= 50:\n            break\n        bonus = rested\n        rested -= bonus\n        xp += g + bonus\n        while level < 50 and xp >= 80 + 20 * level:\n            xp -= 80 + 20 * level\n            level += 1\n        if level >= 50:\n            xp = 0\n    return [level, xp, rested]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression rested bonus size #1', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('regression rested bonus size #2', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('partial repair boundary #1', [48, 123, [50, 10, 420], 100], [48, 703, 0]),\n  ('partial repair boundary #2', [48, 108, [300, 300, 99, 86, 300], 30], [49, 183, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100])],\n [('regression rested bonus size #1', [1, 130, [300, 99], 1000], [7, 28, 601]),\n  ('regression rested bonus size #2', [5, 106, [10], 1000], [5, 126, 990]),\n  ('regression rested bonus size #3', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('partial repair boundary #1', [1, 37, [100, 100, 2000], 1000], [15, 17, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100]),\n  ('control #2', [5, 79, [300], 0], [6, 199, 0])],\n [('regression rested bonus size #1', [48, 105, [100], 395], [48, 305, 295]),\n  ('regression rested bonus size #2', [1, 132, [10, 100, 99, 100], 1000], [6, 50, 691]),\n  ('partial repair boundary #1', [1, 15, [100], 100], [2, 115, 0]),\n  ('regression rested bonus size #3', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [5, 79, [300], 0], [6, 199, 0]),\n  ('control #2', [10, 7, [300, 50, 99, 100], 0], [11, 276, 0])],\n [('regression rested bonus size #1', [27, 6, [121], 265], [27, 248, 144]),\n  ('regression rested bonus size #2', [5, 80, [300, 99, 50, 99, 300], 1000], [12, 96, 152]),\n  ('partial repair boundary #1', [5, 102, [50, 100], 30], [6, 102, 0]),\n  ('partial repair boundary #2', [5, 92, [179, 50, 437, 100], 155], [9, 173, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('control #1', [5, 79, [100, 10, 2000], 0], [13, 189, 0]),\n  ('control #2', [29, 125, [2000], 0], [32, 85, 0])],\n [('regression rested bonus size #1', [1, 31, [100], 1000], [3, 11, 900]),\n  ('regression rested bonus size #2', [30, 107, [100], 1000], [30, 307, 900]),\n  ('partial repair boundary #1', [1, 19, [50, 2000, 50], 1000], [14, 259, 0]),\n  ('partial repair boundary #2', [30, 136, [2000, 100], 1000], [34, 396, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [30, 122, [50, 10, 300, 50, 100], 0], [30, 632, 0]),\n  ('control #2', [50, 12, [2000, 50, 300, 50], 30], [50, 12, 30])]]\nfor label, args, expected in cases[N-1]:\n    check(label, 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":"f05ad58944f74e60c34fa46950b303e7d135d73e4d0e815a10b4220e46a076fd","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(level, xp, gains, rested):\n    for g in gains:\n        if level >= 50:\n            break\n        bonus = min(g, rested)\n        rested -= bonus\n        xp += g + bonus\n        while level < 50 and xp >= 80 + 20 * level:\n            xp -= 80 + 20 * level\n            level += 1\n        if level >= 50:\n            xp = 0\n    return [level, xp, rested]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression rested bonus size #1', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('regression rested bonus size #2', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('partial repair boundary #1', [48, 123, [50, 10, 420], 100], [48, 703, 0]),\n  ('partial repair boundary #2', [48, 108, [300, 300, 99, 86, 300], 30], [49, 183, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100])],\n [('regression rested bonus size #1', [1, 130, [300, 99], 1000], [7, 28, 601]),\n  ('regression rested bonus size #2', [5, 106, [10], 1000], [5, 126, 990]),\n  ('regression rested bonus size #3', [30, 20, [50, 100, 10, 10], 1000], [30, 360, 830]),\n  ('partial repair boundary #1', [1, 37, [100, 100, 2000], 1000], [15, 17, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [50, 56, [99], 100], [50, 56, 100]),\n  ('control #2', [5, 79, [300], 0], [6, 199, 0])],\n [('regression rested bonus size #1', [48, 105, [100], 395], [48, 305, 295]),\n  ('regression rested bonus size #2', [1, 132, [10, 100, 99, 100], 1000], [6, 50, 691]),\n  ('partial repair boundary #1', [1, 15, [100], 100], [2, 115, 0]),\n  ('regression rested bonus size #3', [48, 26, [100, 99], 1000], [48, 424, 801]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('control #1', [5, 79, [300], 0], [6, 199, 0]),\n  ('control #2', [10, 7, [300, 50, 99, 100], 0], [11, 276, 0])],\n [('regression rested bonus size #1', [27, 6, [121], 265], [27, 248, 144]),\n  ('regression rested bonus size #2', [5, 80, [300, 99, 50, 99, 300], 1000], [12, 96, 152]),\n  ('partial repair boundary #1', [5, 102, [50, 100], 30], [6, 102, 0]),\n  ('partial repair boundary #2', [5, 92, [179, 50, 437, 100], 155], [9, 173, 0]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('exact threshold #1', [10, 0, [280], 0], [11, 0, 0]),\n  ('control #1', [5, 79, [100, 10, 2000], 0], [13, 189, 0]),\n  ('control #2', [29, 125, [2000], 0], [32, 85, 0])],\n [('regression rested bonus size #1', [1, 31, [100], 1000], [3, 11, 900]),\n  ('regression rested bonus size #2', [30, 107, [100], 1000], [30, 307, 900]),\n  ('partial repair boundary #1', [1, 19, [50, 2000, 50], 1000], [14, 259, 0]),\n  ('partial repair boundary #2', [30, 136, [2000, 100], 1000], [34, 396, 0]),\n  ('gain at cap keeps rested #1', [50, 0, [100], 40], [50, 0, 40]),\n  ('multi-level gain #1', [1, 0, [300], 0], [3, 80, 0]),\n  ('control #1', [30, 122, [50, 10, 300, 50, 100], 0], [30, 632, 0]),\n  ('control #2', [50, 12, [2000, 50, 300, 50], 30], [50, 12, 30])]]\nfor label, args, expected in cases[N-1]:\n    check(label, 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":"Deterministic toy contract stipulated for this model; integer or exact arithmetic only, not a reproduction of any specific game engine. 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-game-economy-crafting-balance-rested-xp-rested-bonus-size","generated_at":"2026-09-29T14:50:48.305260+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Game economies leak or destroy currency when one crafting or pricing rule is off by one boundary, rounding stage or state update; the defect is observable in exact integer outcomes.","repair":"Restore `bonus = min(g, rested)` at the rested bonus size step.","root_cause":"The rested bonus is not limited to the size of the gain.","sha256":"8641515e410b322e1ed279d27b1351bb5cfd9e20cacb2a2014cb12ae96fd6c8f","title":"Crafting XP with rested pool: One kill drains the whole rested pool · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":37.096,"exit_code":1,"observations":[{"actual":[30,275,915],"check":"regression rested bonus size #1","expected":[30,360,830],"passed":false},{"actual":[48,324,901],"check":"regression rested bonus size #2","expected":[48,424,801],"passed":false},{"actual":[48,668,35],"check":"partial repair boundary #1","expected":[48,703,0],"passed":false},{"actual":[49,182,1],"check":"partial repair boundary #2","expected":[49,183,0],"passed":false},{"actual":[3,80,0],"check":"multi-level gain #1","expected":[3,80,0],"passed":true},{"actual":[11,0,0],"check":"exact threshold #1","expected":[11,0,0],"passed":true},{"actual":[50,0,40],"check":"gain at cap keeps rested #1","expected":[50,0,40],"passed":true},{"actual":[50,56,100],"check":"control #1","expected":[50,56,100],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression rested bonus size #1\", \"actual\": [30, 275, 915], \"expected\": [30, 360, 830], \"passed\": false}, {\"check\": \"regression rested bonus size #2\", \"actual\": [48, 324, 901], \"expected\": [48, 424, 801], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [48, 668, 35], \"expected\": [48, 703, 0], \"passed\": false}, {\"check\": \"partial repair boundary #2\", \"actual\": [49, 182, 1], \"expected\": [49, 183, 0], \"passed\": false}, {\"check\": \"multi-level gain #1\", \"actual\": [3, 80, 0], \"expected\": [3, 80, 0], \"passed\": true}, {\"check\": \"exact threshold #1\", \"actual\": [11, 0, 0], \"expected\": [11, 0, 0], \"passed\": true}, {\"check\": \"gain at cap keeps rested #1\", \"actual\": [50, 0, 40], \"expected\": [50, 0, 40], \"passed\": true}, {\"check\": \"control #1\", \"actual\": [50, 56, 100], \"expected\": [50, 56, 100], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.523,"exit_code":1,"observations":[{"actual":[31,510,0],"check":"regression rested bonus size #1","expected":[30,360,830],"passed":false},{"actual":[49,185,0],"check":"regression rested bonus size #2","expected":[48,424,801],"passed":false},{"actual":[48,703,0],"check":"partial repair boundary #1","expected":[48,703,0],"passed":true},{"actual":[49,183,0],"check":"partial repair boundary #2","expected":[49,183,0],"passed":true},{"actual":[3,80,0],"check":"multi-level gain #1","expected":[3,80,0],"passed":true},{"actual":[11,0,0],"check":"exact threshold #1","expected":[11,0,0],"passed":true},{"actual":[50,0,40],"check":"gain at cap keeps rested #1","expected":[50,0,40],"passed":true},{"actual":[50,56,100],"check":"control #1","expected":[50,56,100],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression rested bonus size #1\", \"actual\": [31, 510, 0], \"expected\": [30, 360, 830], \"passed\": false}, {\"check\": \"regression rested bonus size #2\", \"actual\": [49, 185, 0], \"expected\": [48, 424, 801], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [48, 703, 0], \"expected\": [48, 703, 0], \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": [49, 183, 0], \"expected\": [49, 183, 0], \"passed\": true}, {\"check\": \"multi-level gain #1\", \"actual\": [3, 80, 0], \"expected\": [3, 80, 0], \"passed\": true}, {\"check\": \"exact threshold #1\", \"actual\": [11, 0, 0], \"expected\": [11, 0, 0], \"passed\": true}, {\"check\": \"gain at cap keeps rested #1\", \"actual\": [50, 0, 40], \"expected\": [50, 0, 40], \"passed\": true}, {\"check\": \"control #1\", \"actual\": [50, 56, 100], \"expected\": [50, 56, 100], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":36.768,"exit_code":0,"observations":[{"actual":[30,360,830],"check":"regression rested bonus size #1","expected":[30,360,830],"passed":true},{"actual":[48,424,801],"check":"regression rested bonus size #2","expected":[48,424,801],"passed":true},{"actual":[48,703,0],"check":"partial repair boundary #1","expected":[48,703,0],"passed":true},{"actual":[49,183,0],"check":"partial repair boundary #2","expected":[49,183,0],"passed":true},{"actual":[3,80,0],"check":"multi-level gain #1","expected":[3,80,0],"passed":true},{"actual":[11,0,0],"check":"exact threshold #1","expected":[11,0,0],"passed":true},{"actual":[50,0,40],"check":"gain at cap keeps rested #1","expected":[50,0,40],"passed":true},{"actual":[50,56,100],"check":"control #1","expected":[50,56,100],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression rested bonus size #1\", \"actual\": [30, 360, 830], \"expected\": [30, 360, 830], \"passed\": true}, {\"check\": \"regression rested bonus size #2\", \"actual\": [48, 424, 801], \"expected\": [48, 424, 801], \"passed\": true}, {\"check\": \"partial repair boundary #1\", \"actual\": [48, 703, 0], \"expected\": [48, 703, 0], \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": [49, 183, 0], \"expected\": [49, 183, 0], \"passed\": true}, {\"check\": \"multi-level gain #1\", \"actual\": [3, 80, 0], \"expected\": [3, 80, 0], \"passed\": true}, {\"check\": \"exact threshold #1\", \"actual\": [11, 0, 0], \"expected\": [11, 0, 0], \"passed\": true}, {\"check\": \"gain at cap keeps rested #1\", \"actual\": [50, 0, 40], \"expected\": [50, 0, 40], \"passed\": true}, {\"check\": \"control #1\", \"actual\": [50, 56, 100], \"expected\": [50, 56, 100], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}