FAILURE MAP
← Case archive

FA-73791 / Rate limiter algorithms / Open access

Rolling window over a ring of sub-window counters: rolling total includes expired slots · case 01

After an idle period, slots from long ago still count toward the limit.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The total sums every slot regardless of the epoch it holds.

THE FAILURE

The total sums every slot regardless of the epoch it holds.

Unsuccessful approach: Summing only the last half of the ring under-counts the window.

Case contract

Input {slots N, slot_ms B, limit, requests [t]} with nondecreasing t. Epoch e = t div B maps to slot e mod N; each slot remembers the epoch it counts and is zeroed when reused for a newer epoch. The rolling total sums slots whose epoch lies in (e - N, e]. Admit while total < limit and count the request in the current slot. Return [decisions, slot counts, slot epochs].

Why this case matters

Rolling-window limiters in service meshes keep a ring of small buckets; forgetting to zero reused buckets or summing stale ones replays old traffic into current decisions.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    N = x['slots']
    B = x['slot_ms']
    lim = x['limit']
    cnt = [0] * N
    ep = [-1] * N
    out = []
    for t in x['requests']:
        e = t // B
        s = e % N
        if ep[s] != e:
            ep[s] = e
            cnt[s] = 0
        total = sum(cnt)
        if total < lim:
            cnt[s] += 1
            out.append('allow')
        else:
            out.append('deny')
    return [out, cnt, ep]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 401, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 501, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5001, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 252, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 201, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [46, 120, 415, 554, 645, 818, 865, 1373, 1525, 1554, 1664, 1801, 1833, 1867],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny'],
    [2, 1, 0, 1, 1],
    [15, 16, -1, 18, 4]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 402, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 502, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5002, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 253, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 202, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [98, 199, 284, 322, 376, 477, 477, 489, 1105, 1133, 1150, 1440, 1769, 1950],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow'],
    [1, 3, 1, 1, 1],
    [0, 11, 17, 3, 19]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 403, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 503, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5003, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 254, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 203, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [81, 356, 399, 715, 737, 761, 1248, 1286, 1450, 1484, 1518, 1539, 1635, 1691],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'deny'],
    [0, 0, 2, 2, 2],
    [15, 16, 12, 3, 14]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 404, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 504, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5004, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 255, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 204, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [39, 260, 414, 610, 686, 731, 892, 1075, 1107, 1491, 1496, 1594, 1832, 1860],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny'],
    [1, 1, 1, 1, 2],
    [15, 11, 7, 18, 14]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 405, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 505, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5005, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 256, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 205, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [2, 79, 224, 260, 340, 480, 497, 648, 755, 916, 1103, 1554, 1762, 1944],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow'],
    [1, 1, 1, 0, 1],
    [15, 11, 17, 3, 19]]]]]
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 fixtureActualExpectedOutcome
slot reused after a lap[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]Passed
old slots leave the window[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'], [1, 1, 1, 1, 0], [5, 6, 2, 3, -1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'], [1, 1, 1, 1, 0], [5, 6, 2, 3, -1]]Passed
long idle gap[['allow', 'allow', 'allow', 'deny', 'deny'], [1, 1, 0], [0, 25, -1]][['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]Failed
slot index uses epoch[['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'], [4, 1, 0, 0], [0, 1, 2, 3]][['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'], [4, 1, 0, 0], [0, 1, 2, 3]]Passed
partial saturation reuse[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]Passed
random traffic[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'allow', 'allow', 'deny', 'allow', 'allow', 'deny', 'deny'], [1, 1, 0, 1, 1], [15, 16, -1, 18, 4]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'], [2, 1, 0, 1, 1], [15, 16, -1, 18, 4]]Failed

SHA-256 / 29c47e7ac98e7f9f3e102f5e91c0c3ed269a65fdeb07c76376b243bf2168b357

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    N = x['slots']
    B = x['slot_ms']
    lim = x['limit']
    cnt = [0] * N
    ep = [-1] * N
    out = []
    for t in x['requests']:
        e = t // B
        s = e % N
        if ep[s] != e:
            ep[s] = e
            cnt[s] = 0
        total = sum(cnt[i] for i in range(N) if e - N // 2 <= ep[i] <= e)
        if total < lim:
            cnt[s] += 1
            out.append('allow')
        else:
            out.append('deny')
    return [out, cnt, ep]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 401, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 501, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5001, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 252, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 201, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [46, 120, 415, 554, 645, 818, 865, 1373, 1525, 1554, 1664, 1801, 1833, 1867],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny'],
    [2, 1, 0, 1, 1],
    [15, 16, -1, 18, 4]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 402, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 502, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5002, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 253, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 202, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [98, 199, 284, 322, 376, 477, 477, 489, 1105, 1133, 1150, 1440, 1769, 1950],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow'],
    [1, 3, 1, 1, 1],
    [0, 11, 17, 3, 19]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 403, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 503, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5003, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 254, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 203, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [81, 356, 399, 715, 737, 761, 1248, 1286, 1450, 1484, 1518, 1539, 1635, 1691],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'deny'],
    [0, 0, 2, 2, 2],
    [15, 16, 12, 3, 14]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 404, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 504, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5004, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 255, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 204, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [39, 260, 414, 610, 686, 731, 892, 1075, 1107, 1491, 1496, 1594, 1832, 1860],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'deny'],
    [1, 1, 1, 1, 2],
    [15, 11, 7, 18, 14]]]],
 [['slot reused after a lap',
   {'limit': 3, 'requests': [0, 10, 20, 405, 410, 420, 430], 'slot_ms': 100, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]],
  ['old slots leave the window',
   {'limit': 4, 'requests': [0, 100, 200, 300, 505, 610, 620, 630], 'slot_ms': 100, 'slots': 5},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'],
    [1, 1, 1, 1, 0],
    [5, 6, 2, 3, -1]]],
  ['long idle gap',
   {'limit': 2, 'requests': [0, 250, 5005, 5010, 5020], 'slot_ms': 200, 'slots': 3},
   [['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]],
  ['slot index uses epoch',
   {'limit': 5, 'requests': [0, 1, 2, 3, 256, 252, 503, 999], 'slot_ms': 250, 'slots': 4},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'],
    [4, 1, 0, 0],
    [0, 1, 2, 3]]],
  ['partial saturation reuse',
   {'limit': 5, 'requests': [0, 1, 150, 205, 201, 202, 203, 204], 'slot_ms': 100, 'slots': 2},
   [['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]],
  ['random traffic',
   {'limit': 4,
    'requests': [2, 79, 224, 260, 340, 480, 497, 648, 755, 916, 1103, 1554, 1762, 1944],
    'slot_ms': 100,
    'slots': 5},
   [['allow',
     'allow',
     'allow',
     'allow',
     'deny',
     'deny',
     'deny',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow',
     'allow'],
    [1, 1, 1, 0, 1],
    [15, 11, 17, 3, 19]]]]]
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 fixtureActualExpectedOutcome
slot reused after a lap[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [3, 0, 0, 0], [4, -1, -1, -1]]Passed
old slots leave the window[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow'], [1, 3, 1, 1, 0], [5, 6, 2, 3, -1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'], [1, 1, 1, 1, 0], [5, 6, 2, 3, -1]]Failed
long idle gap[['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]][['allow', 'allow', 'allow', 'allow', 'deny'], [1, 2, 0], [0, 25, -1]]Passed
slot index uses epoch[['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'allow'], [4, 1, 0, 1], [0, 1, 2, 3]][['allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny', 'deny'], [4, 1, 0, 0], [0, 1, 2, 3]]Failed
partial saturation reuse[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny'], [4, 1], [2, 1]]Passed
random traffic[['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'allow'], [2, 1, 0, 3, 1], [15, 16, -1, 18, 4]][['allow', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'allow', 'allow', 'allow', 'allow', 'allow', 'deny', 'deny'], [2, 1, 0, 1, 1], [15, 16, -1, 18, 4]]Failed

SHA-256 / 9cad946d18aa04c5946a5babc95980fc0c29637ee2e153b3eebccc309dff6cc2

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 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

A deterministic, bounded teaching model with stipulated constants and pre-hashed or explicitly hashed inputs; it is not a production implementation and makes no claim of conformance to any library or paper beyond the stated contract. 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:48:50.709786+00:00.

Case digest / 25545baa94da115d45af020ce7ec278b45b91217ee48dad321b2897968dc195a