FAILURE MAP
← Case archive

FA-68231 / Traffic signal timing plans / Open access

Loop detector count and occupancy binning: vehicles are counted in the bin where they leave · case 01

Loop detector count and occupancy binning returns a wrong result when vehicles are counted in the bin where they leave.

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

ROOT CAUSE

Counting at the off time moves vehicles that straddle a bin boundary into the next bin.

VERIFIED REPAIR

Restore the count bin rule so that the step reads `b = on // I`.

Unsuccessful approach: Counting at the midpoint still misplaces vehicles whose presence straddles a boundary.

Case contract

Input {interval s, bins, events: [[on, off]] seconds relative to period start (on may be negative), max_presence, no_activity}. A vehicle is counted in the bin of its on time if inside the period; occupied time is split across bins by overlap; occupancy percent is floor(occupied*100/interval). Status is 'stuck-on' if any presence lasts >= max_presence, 'no-activity' if there are no events and the period (bins*interval) is >= no_activity, else 'ok'. Return {counts, occ_pct, status}.

Why this case matters

Signal timing arithmetic is exact and integer or rational; a wrong rule silently produces unsafe or inefficient timing plans.

1 / The failure

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

N = 1
observations = []
def solve(x):
    I = x['interval']
    B = x['bins']
    counts = [0] * B
    occ = [0] * B
    status = 'ok'
    for on, off in sorted(x['events']):
        b = off // I
        if 0 <= b < B:
            counts[b] += 1
        if off - on >= x['max_presence']:
            status = 'stuck-on'
        for k in range(B):
            lo, hi = k * I, (k + 1) * I
            occ[k] += max(0, min(off, hi) - max(on, lo))
    if not x['events'] and B * I >= x['no_activity']:
        status = 'no-activity'
    return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[455, 463], [31, 33], [419, 422], [1, 4], [53, 58], [96, 391], [78, 79], [439, 441]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[8, 16], [44, 45], [72, 80], [101, 102]], 'max_presence': 240, 'no_activity': 240}, {'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-14, -6], [31, 34], [55, 95], [124, 164], [188, 190], [194, 197], [222, 230]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[0, 8], [32, 33], [54, 57], [84, 124], [155, 160], [187, 189]], 'max_presence': 180, 'no_activity': 120}, {'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 4, 'events': [[4, 7]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 5, 'events': [[-15, -10], [27, 30]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [5, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [[-20, -12], [0, 1], [32, 37], [58, 98], [105, 108], [112, 152]], 'max_presence': 180, 'no_activity': 60}, {'counts': [5, 0], 'occ_pct': [47, 26], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [[58, 59], [86, 89], [34, 36], [8, 13]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0, 0, 0], 'occ_pct': [13, 5, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[-5, 0], [590, 593], [346, 555], [38, 235], [305, 306], [644, 652], [273, 274], [629, 631]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 1, 0], 'occ_pct': [0, 73, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 2, 'events': [[-9, -8], [31, 36], [72, 74], [88, 91], [93, 94]], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 1], 'occ_pct': [0, 16], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[213, 214], [61, 62], [0, 40], [177, 179], [99, 139]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 2, 1], 'occ_pct': [66, 36, 35], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-4, -3], [28, 68], [96, 97], [116, 121], [153, 155]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 2], 'occ_pct': [53, 21], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 4, 'events': [[-20, -15], [8, 13], [48, 49], [82, 85], [101, 104], [132, 133], [165, 168], [201, 202]], 'max_presence': 240, 'no_activity': 600}, {'counts': [4, 3, 0, 0], 'occ_pct': [10, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'})], [({'interval': 30, 'bins': 4, 'events': [[2, 42], [52, 57], [92, 93], [106, 107], [127, 231], [259, 299]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 2], 'occ_pct': [93, 56, 0, 6], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[-10, -7], [12, 14], [51, 59], [61, 101], [134, 137]], 'max_presence': 180, 'no_activity': 60}, {'counts': [3, 1, 0, 0], 'occ_pct': [41, 2, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [[-3, 301], [324, 332], [344, 346]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [100, 100, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[1, 2], [17, 25], [60, 65], [67, 69], [86, 87]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 3], 'occ_pct': [15, 13], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [[-11, -6], [17, 20], [27, 67]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 0, 0, 0], 'occ_pct': [60, 11, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [[-8, 0], [31, 71], [93, 94]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 1, 0, 0], 'occ_pct': [48, 20, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[10, 13], [49, 54], [90, 98]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [10, 16, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[9, 17], [26, 31], [46, 51], [88, 93], [109, 114]], 'max_presence': 240, 'no_activity': 600}, {'counts': [5, 0, 0, 0], 'occ_pct': [23, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, 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
timing oracle 0{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}Passed
timing oracle 1{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}Passed
timing oracle 2{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}Passed
timing oracle 3{'counts': [1, 2], 'occ_pct': [8, 6], 'status': 'ok'}{'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}Failed
timing oracle 4{'counts': [0, 1, 0, 1], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}{'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}Failed
timing oracle 5{'counts': [0, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}{'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}Failed
timing oracle 6{'counts': [3, 3, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}{'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}Failed
timing oracle 7{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}Passed

SHA-256 / 1d92b7a1ecfa1bad820100ada8c82661379ef4b94050c2d4cdffedf9176d9d94

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    I = x['interval']
    B = x['bins']
    counts = [0] * B
    occ = [0] * B
    status = 'ok'
    for on, off in sorted(x['events']):
        b = (on + off) // 2 // I
        if 0 <= b < B:
            counts[b] += 1
        if off - on >= x['max_presence']:
            status = 'stuck-on'
        for k in range(B):
            lo, hi = k * I, (k + 1) * I
            occ[k] += max(0, min(off, hi) - max(on, lo))
    if not x['events'] and B * I >= x['no_activity']:
        status = 'no-activity'
    return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[455, 463], [31, 33], [419, 422], [1, 4], [53, 58], [96, 391], [78, 79], [439, 441]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[8, 16], [44, 45], [72, 80], [101, 102]], 'max_presence': 240, 'no_activity': 240}, {'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-14, -6], [31, 34], [55, 95], [124, 164], [188, 190], [194, 197], [222, 230]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[0, 8], [32, 33], [54, 57], [84, 124], [155, 160], [187, 189]], 'max_presence': 180, 'no_activity': 120}, {'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 4, 'events': [[4, 7]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 5, 'events': [[-15, -10], [27, 30]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [5, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [[-20, -12], [0, 1], [32, 37], [58, 98], [105, 108], [112, 152]], 'max_presence': 180, 'no_activity': 60}, {'counts': [5, 0], 'occ_pct': [47, 26], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [[58, 59], [86, 89], [34, 36], [8, 13]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0, 0, 0], 'occ_pct': [13, 5, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[-5, 0], [590, 593], [346, 555], [38, 235], [305, 306], [644, 652], [273, 274], [629, 631]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 1, 0], 'occ_pct': [0, 73, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 2, 'events': [[-9, -8], [31, 36], [72, 74], [88, 91], [93, 94]], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 1], 'occ_pct': [0, 16], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[213, 214], [61, 62], [0, 40], [177, 179], [99, 139]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 2, 1], 'occ_pct': [66, 36, 35], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-4, -3], [28, 68], [96, 97], [116, 121], [153, 155]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 2], 'occ_pct': [53, 21], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 4, 'events': [[-20, -15], [8, 13], [48, 49], [82, 85], [101, 104], [132, 133], [165, 168], [201, 202]], 'max_presence': 240, 'no_activity': 600}, {'counts': [4, 3, 0, 0], 'occ_pct': [10, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'})], [({'interval': 30, 'bins': 4, 'events': [[2, 42], [52, 57], [92, 93], [106, 107], [127, 231], [259, 299]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 2], 'occ_pct': [93, 56, 0, 6], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[-10, -7], [12, 14], [51, 59], [61, 101], [134, 137]], 'max_presence': 180, 'no_activity': 60}, {'counts': [3, 1, 0, 0], 'occ_pct': [41, 2, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [[-3, 301], [324, 332], [344, 346]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [100, 100, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[1, 2], [17, 25], [60, 65], [67, 69], [86, 87]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 3], 'occ_pct': [15, 13], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [[-11, -6], [17, 20], [27, 67]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 0, 0, 0], 'occ_pct': [60, 11, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [[-8, 0], [31, 71], [93, 94]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 1, 0, 0], 'occ_pct': [48, 20, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[10, 13], [49, 54], [90, 98]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [10, 16, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[9, 17], [26, 31], [46, 51], [88, 93], [109, 114]], 'max_presence': 240, 'no_activity': 600}, {'counts': [5, 0, 0, 0], 'occ_pct': [23, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, 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
timing oracle 0{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}Passed
timing oracle 1{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}Passed
timing oracle 2{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}Passed
timing oracle 3{'counts': [0, 2], 'occ_pct': [8, 6], 'status': 'ok'}{'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}Failed
timing oracle 4{'counts': [0, 1, 1, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}{'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}Failed
timing oracle 5{'counts': [0, 0, 0, 1], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}{'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}Failed
timing oracle 6{'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}{'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}Passed
timing oracle 7{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}Passed

SHA-256 / 50e9864cd96091ca89e4c4d48116654f610e23f5f178edbe5123f81916c41540

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    I = x['interval']
    B = x['bins']
    counts = [0] * B
    occ = [0] * B
    status = 'ok'
    for on, off in sorted(x['events']):
        b = on // I
        if 0 <= b < B:
            counts[b] += 1
        if off - on >= x['max_presence']:
            status = 'stuck-on'
        for k in range(B):
            lo, hi = k * I, (k + 1) * I
            occ[k] += max(0, min(off, hi) - max(on, lo))
    if not x['events'] and B * I >= x['no_activity']:
        status = 'no-activity'
    return {'counts': counts, 'occ_pct': [o * 100 // I for o in occ], 'status': status}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 2, 'events': [[455, 463], [31, 33], [419, 422], [1, 4], [53, 58], [96, 391], [78, 79], [439, 441]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[8, 16], [44, 45], [72, 80], [101, 102]], 'max_presence': 240, 'no_activity': 240}, {'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-14, -6], [31, 34], [55, 95], [124, 164], [188, 190], [194, 197], [222, 230]], 'max_presence': 100, 'no_activity': 600}, {'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 3, 'events': [[0, 8], [32, 33], [54, 57], [84, 124], [155, 160], [187, 189]], 'max_presence': 180, 'no_activity': 120}, {'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 4, 'events': [[4, 7]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'})], [({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 5, 'events': [[-15, -10], [27, 30]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [5, 0, 0, 0, 0], 'status': 'ok'}), ({'interval': 120, 'bins': 2, 'events': [[-20, -12], [0, 1], [32, 37], [58, 98], [105, 108], [112, 152]], 'max_presence': 180, 'no_activity': 60}, {'counts': [5, 0], 'occ_pct': [47, 26], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [[58, 59], [86, 89], [34, 36], [8, 13]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0, 0, 0], 'occ_pct': [13, 5, 0, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[-5, 0], [590, 593], [346, 555], [38, 235], [305, 306], [644, 652], [273, 274], [629, 631]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 1, 0], 'occ_pct': [0, 73, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 2, 'events': [[-9, -8], [31, 36], [72, 74], [88, 91], [93, 94]], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 1], 'occ_pct': [0, 16], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [[213, 214], [61, 62], [0, 40], [177, 179], [99, 139]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 2, 1], 'occ_pct': [66, 36, 35], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 600}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-4, -3], [28, 68], [96, 97], [116, 121], [153, 155]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 2], 'occ_pct': [53, 21], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 120, 'bins': 4, 'events': [[-20, -15], [8, 13], [48, 49], [82, 85], [101, 104], [132, 133], [165, 168], [201, 202]], 'max_presence': 240, 'no_activity': 600}, {'counts': [4, 3, 0, 0], 'occ_pct': [10, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'})], [({'interval': 30, 'bins': 4, 'events': [[2, 42], [52, 57], [92, 93], [106, 107], [127, 231], [259, 299]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 0, 2], 'occ_pct': [93, 56, 0, 6], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[-10, -7], [12, 14], [51, 59], [61, 101], [134, 137]], 'max_presence': 180, 'no_activity': 60}, {'counts': [3, 1, 0, 0], 'occ_pct': [41, 2, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 240, 'no_activity': 240}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 3, 'events': [[-3, 301], [324, 332], [344, 346]], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [100, 100, 100], 'status': 'stuck-on'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[1, 2], [17, 25], [60, 65], [67, 69], [86, 87]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 3], 'occ_pct': [15, 13], 'status': 'ok'})], [({'interval': 60, 'bins': 4, 'events': [[-11, -6], [17, 20], [27, 67]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 0, 0, 0], 'occ_pct': [60, 11, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 2, 'events': [[-5, 3], [58, 63], [70, 71]], 'max_presence': 180, 'no_activity': 120}, {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}), ({'interval': 60, 'bins': 5, 'events': [], 'max_presence': 100, 'no_activity': 120}, {'counts': [0, 0, 0, 0, 0], 'occ_pct': [0, 0, 0, 0, 0], 'status': 'no-activity'}), ({'interval': 60, 'bins': 4, 'events': [[-8, 0], [31, 71], [93, 94]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 1, 0, 0], 'occ_pct': [48, 20, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 3, 'events': [[10, 13], [49, 54], [90, 98]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [10, 16, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[0, 180]], 'max_presence': 180, 'no_activity': 60}, {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 4, 'events': [[9, 17], [26, 31], [46, 51], [88, 93], [109, 114]], 'max_presence': 240, 'no_activity': 600}, {'counts': [5, 0, 0, 0], 'occ_pct': [23, 0, 0, 0], 'status': 'ok'})]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check('timing oracle' + ' %d' % i, 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
timing oracle 0{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}{'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}Passed
timing oracle 1{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}{'counts': [1, 2], 'occ_pct': [10, 23], 'status': 'stuck-on'}Passed
timing oracle 2{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}{'counts': [4, 0, 0, 0], 'occ_pct': [15, 0, 0, 0], 'status': 'ok'}Passed
timing oracle 3{'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}{'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'}Passed
timing oracle 4{'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}{'counts': [0, 2, 0, 0], 'occ_pct': [0, 26, 100, 16], 'status': 'ok'}Passed
timing oracle 5{'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}{'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'}Passed
timing oracle 6{'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}{'counts': [4, 2, 0], 'occ_pct': [40, 9, 0], 'status': 'ok'}Passed
timing oracle 7{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}{'counts': [1, 0, 0, 0], 'occ_pct': [5, 0, 0, 0], 'status': 'ok'}Passed

SHA-256 / 241df7ef57533bed6812cf91f2062500b663251c9e788e7a17b8ae458fc71e5b

Verification & scope

A deterministic, bounded toy model with a stipulated contract; it makes no claim of conformance to any agency manual or standard. 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:00.282689+00:00.

Case digest / 2eddfdc65ab1a6ec70943f0292e41c12ff0459c3b625cd5995eb80980657bcd6