FA-86101 / Game economy crafting balance / Open access
Stamina regeneration: Events apply in submission order · case 01
Late-submitted early events regenerate backward in time.
ROOT CAUSE
Events are processed in list order instead of time order.
THE FAILURE
Events are processed in list order instead of time order.
Unsuccessful approach: Sorting by amount instead of time still processes events out of chronological order.
Case 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].
Why this case matters
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.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(stamina, cap, last_tick, now, refills):
events = refills + [[now, 0]]
t = last_tick
s = stamina
for at, amount in events:
if s < cap:
gained = (at - t) // 300
if s + gained >= cap:
s = cap
t = at
else:
s += gained
t += gained * 300
else:
t = at
if s + amount >= 0:
s = min(999, s + amount)
return [s, t]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression event ordering #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('regression event ordering #2', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266])],
[('fault site event ordering #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),
('regression event ordering #1', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),
('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),
('control #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],
[('regression event ordering #1', [9, 6, 0, 299, [[276, -6], [47, -6], [269, -6]]], [3, 47]),
('regression event ordering #2', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),
('regression event ordering #3', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),
('regression event ordering #4', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('control #1', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('control #2', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010])],
[('regression event ordering #1', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),
('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),
('regression event ordering #3', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),
('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('control #1', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),
('control #2', [4, 13, 569, 868, [[776, 10]]], [14, 868])],
[('fault site event ordering #1', [8, 5, 536, 1136, [[967, 5], [915, -10]]], [13, 1136]),
('regression event ordering #1', [4, 5, 685, 984, [[969, -9], [731, -5], [931, 5]]], [0, 969]),
('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),
('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [17, 18, 353, 353, []], [17, 353]),
('control #2', [0, 18, 176, 176, []], [0, 176])]]
for label, args, expected in cases[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression event ordering #1 | [22, 1572] | [3, 1315] | Failed |
| regression event ordering #2 | [40, 1288] | [39, 1288] | Failed |
| partial repair boundary #1 | [45, 982] | [45, 982] | Passed |
| partial repair boundary #2 | [14, 2462] | [14, 2462] | Passed |
| exact refill to cap #1 | [5, 600] | [5, 600] | Passed |
| overflow potion persists #1 | [15, 1200] | [15, 1200] | Passed |
| spend from full restarts timer #1 | [8, 1000] | [8, 1000] | Passed |
| control #1 | [0, 266] | [0, 266] | Passed |
SHA-256 / bb785a95b8125d7d23eaa355df01dbca5cf530ef905de6ca9a28e98b4e5fb917
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(stamina, cap, last_tick, now, refills):
events = sorted(refills, key=lambda e: e[1]) + [[now, 0]]
t = last_tick
s = stamina
for at, amount in events:
if s < cap:
gained = (at - t) // 300
if s + gained >= cap:
s = cap
t = at
else:
s += gained
t += gained * 300
else:
t = at
if s + amount >= 0:
s = min(999, s + amount)
return [s, t]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression event ordering #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('regression event ordering #2', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266])],
[('fault site event ordering #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),
('regression event ordering #1', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),
('partial repair boundary #1', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('partial repair boundary #2', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),
('control #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583])],
[('regression event ordering #1', [9, 6, 0, 299, [[276, -6], [47, -6], [269, -6]]], [3, 47]),
('regression event ordering #2', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),
('regression event ordering #3', [20, 17, 920, 1520, [[1180, -17], [1013, -17], [1246, -5]]], [4, 1313]),
('regression event ordering #4', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('control #1', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('control #2', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010])],
[('regression event ordering #1', [18, 15, 804, 1404, [[1122, -11], [838, -10], [1325, -15]]], [9, 1138]),
('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),
('regression event ordering #3', [0, 12, 931, 4421, [[3673, 12], [2327, 12], [3157, -12]]], [17, 4421]),
('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('control #1', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),
('control #2', [4, 13, 569, 868, [[776, 10]]], [14, 868])],
[('fault site event ordering #1', [8, 5, 536, 1136, [[967, 5], [915, -10]]], [13, 1136]),
('regression event ordering #1', [4, 5, 685, 984, [[969, -9], [731, -5], [931, 5]]], [0, 969]),
('regression event ordering #2', [6, 13, 592, 1192, [[637, 13], [1064, -10], [753, 13]]], [22, 1192]),
('partial repair boundary #1', [19, 19, 941, 1541, [[942, 19], [1061, 19], [1143, -3]]], [54, 1541]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [17, 18, 353, 353, []], [17, 353]),
('control #2', [0, 18, 176, 176, []], [0, 176])]]
for label, args, expected in cases[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression event ordering #1 | [22, 1572] | [3, 1315] | Failed |
| regression event ordering #2 | [40, 1288] | [39, 1288] | Failed |
| partial repair boundary #1 | [43, 982] | [45, 982] | Failed |
| partial repair boundary #2 | [26, 2462] | [14, 2462] | Failed |
| exact refill to cap #1 | [5, 600] | [5, 600] | Passed |
| overflow potion persists #1 | [15, 1200] | [15, 1200] | Passed |
| spend from full restarts timer #1 | [8, 1000] | [8, 1000] | Passed |
| control #1 | [0, 266] | [0, 266] | Passed |
SHA-256 / 01fe79822e19686ba3c61abd5385f34929bd0a5c431674b008efd824e15c2978
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:46.374875+00:00.
Case digest / 1c8ad0dd93fa0674f63748c0878a0e732a866952a31521f0b92ba8ab92a108a0