{"abstract":"A player refilled exactly to cap keeps a stale timer and regains too early after spending.","category":"Game economy crafting balance","checks":8,"contract":"Stamina regenerates 1 per 300 s while below cap, anchored at last_tick. Events [time, amount] are applied in time order (then amount); before each event (and finally at now) regeneration catches up: if it reaches cap the value becomes cap and the anchor moves to the event time, otherwise the anchor advances by whole periods. While at or above cap the anchor follows the event time. Amounts may push stamina above cap up to 999; negative amounts are spends that are rejected if they would go below zero. Return [stamina, anchor].","contract_signature":"stamina, cap, last_tick, now, refills","evaluation_group":"w2-game-economy-crafting-balance-stamina-regen","failed_approach":"Comparing only the gained ticks ignores the current stamina.","family":"w2-game-economy-crafting-balance-stamina-regen-cap-reach-test","id":"FA-86081","implementations":{"attempt":{"sha256":"54d4f7ab5283d41cf34b01d883fd667bbdb4763a0ca29144e321cf96e9f25ea9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(stamina, cap, last_tick, now, refills):\n    events = sorted(refills) + [[now, 0]]\n    t = last_tick\n    s = stamina\n    for at, amount in events:\n        if s < cap:\n            gained = (at - t) // 300\n            if gained >= cap:\n                s = cap\n                t = at\n            else:\n                s += gained\n                t += gained * 300\n        else:\n            t = at\n        if s + amount >= 0:\n            s = min(999, s + amount)\n    return [s, t]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [14, 15, 389, 2081, []], [15, 2081]),\n  ('partial repair boundary #2', [5, 6, 119, 719, []], [6, 719]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266])],\n [('regression cap reach test #1', [7, 8, 694, 1294, [[953, -8], [777, 8]]], [8, 1294]),\n  ('regression cap reach test #2', [5, 6, 52, 1701, [[656, -3]]], [6, 1701]),\n  ('partial repair boundary #1', [10, 11, 108, 708, [[340, -11], [363, -11]]], [11, 708]),\n  ('partial repair boundary #2', [12, 13, 487, 4020, [[1176, -13], [3667, -7]]], [2, 3876]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),\n  ('control #2', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315])],\n [('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [9, 10, 70, 5274, [[4672, -8], [2667, 10], [5260, -10]]], [2, 5260]),\n  ('partial repair boundary #2', [12, 13, 683, 4974, [[4778, -10], [2984, 11]]], [14, 4974]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('control #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),\n  ('control #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],\n [('regression cap reach test #1', [7, 8, 694, 1294, [[953, -8], [777, 8]]], [8, 1294]),\n  ('regression cap reach test #2', [5, 6, 52, 1701, [[656, -3]]], [6, 1701]),\n  ('partial repair boundary #1', [12, 13, 683, 4974, [[4778, -10], [2984, 11]]], [14, 4974]),\n  ('partial repair boundary #2', [4, 14, 252, 4128, [[1747, -14], [1416, -14], [1627, 14]]], [14, 4128]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('control #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),\n  ('control #2', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163])],\n [('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [16, 17, 643, 6372, [[1199, -17], [2262, -17]]], [17, 6372]),\n  ('partial repair boundary #2', [11, 12, 804, 1404, [[1100, -12]]], [12, 1404]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('control #1', [4, 13, 569, 868, [[776, 10]]], [14, 868]),\n  ('control #2', [17, 18, 353, 353, []], [17, 353])]]\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":"95a0af1792550c9fb8b503e534a3d2c26bb8339751b2c8bde854c61c4fc68d99","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(stamina, cap, last_tick, now, refills):\n    events = sorted(refills) + [[now, 0]]\n    t = last_tick\n    s = stamina\n    for at, amount in events:\n        if s < cap:\n            gained = (at - t) // 300\n            if s + gained > cap:\n                s = cap\n                t = at\n            else:\n                s += gained\n                t += gained * 300\n        else:\n            t = at\n        if s + amount >= 0:\n            s = min(999, s + amount)\n    return [s, t]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [14, 15, 389, 2081, []], [15, 2081]),\n  ('partial repair boundary #2', [5, 6, 119, 719, []], [6, 719]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266])],\n [('regression cap reach test #1', [7, 8, 694, 1294, [[953, -8], [777, 8]]], [8, 1294]),\n  ('regression cap reach test #2', [5, 6, 52, 1701, [[656, -3]]], [6, 1701]),\n  ('partial repair boundary #1', [10, 11, 108, 708, [[340, -11], [363, -11]]], [11, 708]),\n  ('partial repair boundary #2', [12, 13, 487, 4020, [[1176, -13], [3667, -7]]], [2, 3876]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),\n  ('control #2', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315])],\n [('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [9, 10, 70, 5274, [[4672, -8], [2667, 10], [5260, -10]]], [2, 5260]),\n  ('partial repair boundary #2', [12, 13, 683, 4974, [[4778, -10], [2984, 11]]], [14, 4974]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('control #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),\n  ('control #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],\n [('regression cap reach test #1', [7, 8, 694, 1294, [[953, -8], [777, 8]]], [8, 1294]),\n  ('regression cap reach test #2', [5, 6, 52, 1701, [[656, -3]]], [6, 1701]),\n  ('partial repair boundary #1', [12, 13, 683, 4974, [[4778, -10], [2984, 11]]], [14, 4974]),\n  ('partial repair boundary #2', [4, 14, 252, 4128, [[1747, -14], [1416, -14], [1627, 14]]], [14, 4128]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),\n  ('control #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),\n  ('control #2', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163])],\n [('regression cap reach test #1', [18, 19, 721, 1321, [[1232, -19]]], [0, 1232]),\n  ('regression cap reach test #2', [21, 18, 543, 6446, [[2575, -18], [4607, -18], [1660, 9]]], [6, 6407]),\n  ('partial repair boundary #1', [16, 17, 643, 6372, [[1199, -17], [2262, -17]]], [17, 6372]),\n  ('partial repair boundary #2', [11, 12, 804, 1404, [[1100, -12]]], [12, 1404]),\n  ('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),\n  ('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),\n  ('control #1', [4, 13, 569, 868, [[776, 10]]], [14, 868]),\n  ('control #2', [17, 18, 353, 353, []], [17, 353])]]\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-stamina-regen-cap-reach-test","generated_at":"2026-09-29T14:50:46.301052+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.","root_cause":"Reaching the cap exactly is handled as a partial regen, leaving a stale anchor.","sha256":"8d088c4739ec55207865ca8ae20d36b4aa63315e41d9eef77a89936b34c4df3b","title":"Stamina regeneration: Reaching cap exactly keeps the old anchor · 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":38.158,"exit_code":1,"observations":[{"actual":[1,1321],"check":"regression cap reach test #1","expected":[0,1232],"passed":false},{"actual":[6,6175],"check":"regression cap reach test #2","expected":[6,6407],"passed":false},{"actual":[19,1889],"check":"partial repair boundary #1","expected":[15,2081],"passed":false},{"actual":[7,719],"check":"partial repair boundary #2","expected":[6,719],"passed":false},{"actual":[5,600],"check":"exact refill to cap #1","expected":[5,600],"passed":true},{"actual":[15,1200],"check":"overflow potion persists #1","expected":[15,1200],"passed":true},{"actual":[8,1000],"check":"spend from full restarts timer #1","expected":[8,1000],"passed":true},{"actual":[0,266],"check":"control #1","expected":[0,266],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression cap reach test #1\", \"actual\": [1, 1321], \"expected\": [0, 1232], \"passed\": false}, {\"check\": \"regression cap reach test #2\", \"actual\": [6, 6175], \"expected\": [6, 6407], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [19, 1889], \"expected\": [15, 2081], \"passed\": false}, {\"check\": \"partial repair boundary #2\", \"actual\": [7, 719], \"expected\": [6, 719], \"passed\": false}, {\"check\": \"exact refill to cap #1\", \"actual\": [5, 600], \"expected\": [5, 600], \"passed\": true}, {\"check\": \"overflow potion persists #1\", \"actual\": [15, 1200], \"expected\": [15, 1200], \"passed\": true}, {\"check\": \"spend from full restarts timer #1\", \"actual\": [8, 1000], \"expected\": [8, 1000], \"passed\": true}, {\"check\": \"control #1\", \"actual\": [0, 266], \"expected\": [0, 266], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.134,"exit_code":1,"observations":[{"actual":[1,1321],"check":"regression cap reach test #1","expected":[0,1232],"passed":false},{"actual":[6,6175],"check":"regression cap reach test #2","expected":[6,6407],"passed":false},{"actual":[15,2081],"check":"partial repair boundary #1","expected":[15,2081],"passed":true},{"actual":[6,719],"check":"partial repair boundary #2","expected":[6,719],"passed":true},{"actual":[5,600],"check":"exact refill to cap #1","expected":[5,600],"passed":true},{"actual":[15,1200],"check":"overflow potion persists #1","expected":[15,1200],"passed":true},{"actual":[8,1000],"check":"spend from full restarts timer #1","expected":[8,1000],"passed":true},{"actual":[0,266],"check":"control #1","expected":[0,266],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression cap reach test #1\", \"actual\": [1, 1321], \"expected\": [0, 1232], \"passed\": false}, {\"check\": \"regression cap reach test #2\", \"actual\": [6, 6175], \"expected\": [6, 6407], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [15, 2081], \"expected\": [15, 2081], \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": [6, 719], \"expected\": [6, 719], \"passed\": true}, {\"check\": \"exact refill to cap #1\", \"actual\": [5, 600], \"expected\": [5, 600], \"passed\": true}, {\"check\": \"overflow potion persists #1\", \"actual\": [15, 1200], \"expected\": [15, 1200], \"passed\": true}, {\"check\": \"spend from full restarts timer #1\", \"actual\": [8, 1000], \"expected\": [8, 1000], \"passed\": true}, {\"check\": \"control #1\", \"actual\": [0, 266], \"expected\": [0, 266], \"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."}}