{"abstract":"Late-submitted early events regenerate backward in time.","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":"Sorting by amount instead of time still processes events out of chronological order.","family":"w2-game-economy-crafting-balance-stamina-regen-event-ordering","id":"FA-86101","implementations":{"attempt":{"sha256":"01fe79822e19686ba3c61abd5385f34929bd0a5c431674b008efd824e15c2978","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, key=lambda e: e[1]) + [[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 event ordering #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),\n  ('regression event ordering #2', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),\n  ('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),\n  ('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),\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 [('fault site event ordering #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),\n  ('regression event ordering #1', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),\n  ('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),\n  ('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),\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', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],\n [('regression event ordering #1', [9, 6, 0, 299, [[276, -6], [47, -6], [269, -6]]], [3, 47]),\n  ('regression event ordering #2', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),\n  ('regression event ordering #3', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),\n  ('regression event ordering #4', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),\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', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),\n  ('control #2', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010])],\n [('regression event ordering #1', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),\n  ('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),\n  ('regression event ordering #3', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),\n  ('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),\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', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),\n  ('control #2', [4, 13, 569, 868, [[776, 10]]], [14, 868])],\n [('fault site event ordering #1', [8, 5, 536, 1136, [[967, 5], [915, -10]]], [13, 1136]),\n  ('regression event ordering #1', [4, 5, 685, 984, [[969, -9], [731, -5], [931, 5]]], [0, 969]),\n  ('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),\n  ('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),\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', [17, 18, 353, 353, []], [17, 353]),\n  ('control #2', [0, 18, 176, 176, []], [0, 176])]]\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":"bb785a95b8125d7d23eaa355df01dbca5cf530ef905de6ca9a28e98b4e5fb917","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 = 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 event ordering #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),\n  ('regression event ordering #2', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),\n  ('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),\n  ('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),\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 [('fault site event ordering #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),\n  ('regression event ordering #1', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),\n  ('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),\n  ('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),\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', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],\n [('regression event ordering #1', [9, 6, 0, 299, [[276, -6], [47, -6], [269, -6]]], [3, 47]),\n  ('regression event ordering #2', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),\n  ('regression event ordering #3', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),\n  ('regression event ordering #4', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),\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', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),\n  ('control #2', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010])],\n [('regression event ordering #1', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),\n  ('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),\n  ('regression event ordering #3', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),\n  ('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),\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', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),\n  ('control #2', [4, 13, 569, 868, [[776, 10]]], [14, 868])],\n [('fault site event ordering #1', [8, 5, 536, 1136, [[967, 5], [915, -10]]], [13, 1136]),\n  ('regression event ordering #1', [4, 5, 685, 984, [[969, -9], [731, -5], [931, 5]]], [0, 969]),\n  ('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),\n  ('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),\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', [17, 18, 353, 353, []], [17, 353]),\n  ('control #2', [0, 18, 176, 176, []], [0, 176])]]\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-event-ordering","generated_at":"2026-09-29T14:50:46.374875+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":"Events are processed in list order instead of time order.","sha256":"1c8ad0dd93fa0674f63748c0878a0e732a866952a31521f0b92ba8ab92a108a0","title":"Stamina regeneration: Events apply in submission order · 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":36.933,"exit_code":1,"observations":[{"actual":[22,1572],"check":"regression event ordering #1","expected":[3,1315],"passed":false},{"actual":[40,1288],"check":"regression event ordering #2","expected":[39,1288],"passed":false},{"actual":[43,982],"check":"partial repair boundary #1","expected":[45,982],"passed":false},{"actual":[26,2462],"check":"partial repair boundary #2","expected":[14,2462],"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 event ordering #1\", \"actual\": [22, 1572], \"expected\": [3, 1315], \"passed\": false}, {\"check\": \"regression event ordering #2\", \"actual\": [40, 1288], \"expected\": [39, 1288], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [43, 982], \"expected\": [45, 982], \"passed\": false}, {\"check\": \"partial repair boundary #2\", \"actual\": [26, 2462], \"expected\": [14, 2462], \"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":40.326,"exit_code":1,"observations":[{"actual":[22,1572],"check":"regression event ordering #1","expected":[3,1315],"passed":false},{"actual":[40,1288],"check":"regression event ordering #2","expected":[39,1288],"passed":false},{"actual":[45,982],"check":"partial repair boundary #1","expected":[45,982],"passed":true},{"actual":[14,2462],"check":"partial repair boundary #2","expected":[14,2462],"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 event ordering #1\", \"actual\": [22, 1572], \"expected\": [3, 1315], \"passed\": false}, {\"check\": \"regression event ordering #2\", \"actual\": [40, 1288], \"expected\": [39, 1288], \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": [45, 982], \"expected\": [45, 982], \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": [14, 2462], \"expected\": [14, 2462], \"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."}}