FA-68241 / Traffic signal timing plans / Open access
Loop detector count and occupancy binning: a presence exactly at the threshold is not stuck · case 01
Loop detector count and occupancy binning returns a wrong result when a presence exactly at the threshold is not stuck.
ROOT CAUSE
A presence lasting exactly the maximum is not diagnosed as stuck-on.
VERIFIED REPAIR
Restore the stuck-on threshold rule so that the step reads `off - on >= x['max_presence']`.
Unsuccessful approach: Ignoring presences that continue past the period hides a detector that is still stuck.
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 = 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': 30, 'bins': 3, 'events': [[189, 197], [8, 9], [30, 38], [68, 71], [80, 120], [160, 161], [221, 395]], 'max_presence': 180, 'no_activity': 240}, {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[1, 233], [234, 236], [250, 258], [267, 272], [284, 287], [313, 315]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], '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': 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': 3, 'events': [[-6, -3], [15, 20], [36, 37]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-19, -11], [15, 16], [31, 36]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 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': 3, 'events': [[5, 234], [236, 244]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [91, 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': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 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': [[-11, 29], [68, 71], [73, 385], [423, 463]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 2], 'occ_pct': [48, 83], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [[-18, 22], [25, 65], [67, 188], [221, 222]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [95, 96, 100], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[-8, -5], [16, 19], [23, 28], [55, 58], [89, 92], [107, 112], [149, 151], [189, 192]], 'max_presence': 100, 'no_activity': 240}, {'counts': [5, 2, 0, 0], 'occ_pct': [15, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [[-15, -13], [-10, -5], [-4, -3], [35, 36], [69, 74], [110, 113]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1], 'occ_pct': [0, 3], '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': 3, 'events': [[7, 344], [378, 688], [724, 764], [781, 821], [836, 1109], [1115, 1117], [1135, 1137], [1138, 1140]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [94, 100, 86], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[1, 204], [238, 240], [251, 603], [638, 678], [704, 712], [739, 779]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0, 0], 'occ_pct': [96, 100, 100, 100], 'status': 'stuck-on'}), ({'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': [[4, 5]], 'max_presence': 240, 'no_activity': 240}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [1, 0, 0, 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': 5, 'events': [[-1, 0], [39, 79], [94, 97], [134, 136]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1, 0, 1, 1], 'occ_pct': [0, 70, 63, 10, 6], 'status': 'ok'})], [({'interval': 60, 'bins': 3, 'events': [[-9, -4], [13, 14], [15, 18], [40, 45], [63, 426], [451, 491], [522, 527], [549, 552]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0], 'occ_pct': [15, 95, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 5, 'events': [[-13, -10], [21, 61], [79, 87], [96, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2, 0, 0, 0], 'occ_pct': [65, 16, 0, 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': 5, 'events': [[3, 8], [14, 17]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [13, 0, 0, 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': 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': 120, 'bins': 2, 'events': [[-13, 27], [55, 400]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 0], 'occ_pct': [76, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 5, 'events': [[2, 7], [24, 27]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [6, 0, 0, 0, 0], 'status': 'ok'})], [({'interval': 30, 'bins': 3, 'events': [[-13, -8], [21, 26], [37, 39], [45, 209], [217, 220], [247, 255], [257, 262], [277, 582]], 'max_presence': 240, 'no_activity': 60}, {'counts': [1, 2, 0], 'occ_pct': [16, 56, 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': 4, 'events': [[-3, 5], [16, 56]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0, 0, 0], 'occ_pct': [75, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[48, 53], [4, 12], [134, 136], [92, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 1], 'occ_pct': [21, 8], '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': 4, 'events': [[2, 3], [22, 62], [76, 78], [116, 124], [142, 147], [173, 175], [215, 220], [255, 258]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 2, 2, 1], 'occ_pct': [65, 13, 18, 8], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | Passed |
| timing oracle 1 | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'ok'} | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | Failed |
| timing oracle 4 | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 5 | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'stuck-on'} | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'stuck-on'} | Passed |
SHA-256 / a1d8250dd2875c3565f3262d47a9884c9588c43f8d877d300173457ac479782b
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 // I
if 0 <= b < B:
counts[b] += 1
if off - on >= x['max_presence'] and off < B * I:
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': 30, 'bins': 3, 'events': [[189, 197], [8, 9], [30, 38], [68, 71], [80, 120], [160, 161], [221, 395]], 'max_presence': 180, 'no_activity': 240}, {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[1, 233], [234, 236], [250, 258], [267, 272], [284, 287], [313, 315]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], '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': 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': 3, 'events': [[-6, -3], [15, 20], [36, 37]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-19, -11], [15, 16], [31, 36]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 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': 3, 'events': [[5, 234], [236, 244]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [91, 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': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 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': [[-11, 29], [68, 71], [73, 385], [423, 463]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 2], 'occ_pct': [48, 83], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [[-18, 22], [25, 65], [67, 188], [221, 222]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [95, 96, 100], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[-8, -5], [16, 19], [23, 28], [55, 58], [89, 92], [107, 112], [149, 151], [189, 192]], 'max_presence': 100, 'no_activity': 240}, {'counts': [5, 2, 0, 0], 'occ_pct': [15, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [[-15, -13], [-10, -5], [-4, -3], [35, 36], [69, 74], [110, 113]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1], 'occ_pct': [0, 3], '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': 3, 'events': [[7, 344], [378, 688], [724, 764], [781, 821], [836, 1109], [1115, 1117], [1135, 1137], [1138, 1140]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [94, 100, 86], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[1, 204], [238, 240], [251, 603], [638, 678], [704, 712], [739, 779]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0, 0], 'occ_pct': [96, 100, 100, 100], 'status': 'stuck-on'}), ({'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': [[4, 5]], 'max_presence': 240, 'no_activity': 240}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [1, 0, 0, 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': 5, 'events': [[-1, 0], [39, 79], [94, 97], [134, 136]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1, 0, 1, 1], 'occ_pct': [0, 70, 63, 10, 6], 'status': 'ok'})], [({'interval': 60, 'bins': 3, 'events': [[-9, -4], [13, 14], [15, 18], [40, 45], [63, 426], [451, 491], [522, 527], [549, 552]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0], 'occ_pct': [15, 95, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 5, 'events': [[-13, -10], [21, 61], [79, 87], [96, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2, 0, 0, 0], 'occ_pct': [65, 16, 0, 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': 5, 'events': [[3, 8], [14, 17]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [13, 0, 0, 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': 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': 120, 'bins': 2, 'events': [[-13, 27], [55, 400]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 0], 'occ_pct': [76, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 5, 'events': [[2, 7], [24, 27]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [6, 0, 0, 0, 0], 'status': 'ok'})], [({'interval': 30, 'bins': 3, 'events': [[-13, -8], [21, 26], [37, 39], [45, 209], [217, 220], [247, 255], [257, 262], [277, 582]], 'max_presence': 240, 'no_activity': 60}, {'counts': [1, 2, 0], 'occ_pct': [16, 56, 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': 4, 'events': [[-3, 5], [16, 56]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0, 0, 0], 'occ_pct': [75, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[48, 53], [4, 12], [134, 136], [92, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 1], 'occ_pct': [21, 8], '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': 4, 'events': [[2, 3], [22, 62], [76, 78], [116, 124], [142, 147], [173, 175], [215, 220], [255, 258]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 2, 2, 1], 'occ_pct': [65, 13, 18, 8], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | Passed |
| timing oracle 1 | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'ok'} | {'counts': [1, 0, 0, 0], 'occ_pct': [100, 100, 100, 100], 'status': 'stuck-on'} | Failed |
| timing oracle 4 | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 5 | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'ok'} | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'stuck-on'} | Failed |
SHA-256 / f8aa3b6eb51cd3f340204c9acc5bbd3802cc679bb7aa031c7e4512aea3672d14
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': 30, 'bins': 3, 'events': [[189, 197], [8, 9], [30, 38], [68, 71], [80, 120], [160, 161], [221, 395]], 'max_presence': 180, 'no_activity': 240}, {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'}), ({'interval': 120, 'bins': 5, 'events': [[1, 233], [234, 236], [250, 258], [267, 272], [284, 287], [313, 315]], 'max_presence': 100, 'no_activity': 240}, {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], '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': 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': 3, 'events': [[-6, -3], [15, 20], [36, 37]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 4, 'events': [[-19, -11], [15, 16], [31, 36]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 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': 3, 'events': [[5, 234], [236, 244]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [91, 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': 30, 'bins': 3, 'events': [], 'max_presence': 180, 'no_activity': 120}, {'counts': [0, 0, 0], 'occ_pct': [0, 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': 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': [[-11, 29], [68, 71], [73, 385], [423, 463]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 2], 'occ_pct': [48, 83], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 3, 'events': [[-18, 22], [25, 65], [67, 188], [221, 222]], 'max_presence': 180, 'no_activity': 600}, {'counts': [1, 1, 0], 'occ_pct': [95, 96, 100], 'status': 'ok'}), ({'interval': 120, 'bins': 4, 'events': [[-8, -5], [16, 19], [23, 28], [55, 58], [89, 92], [107, 112], [149, 151], [189, 192]], 'max_presence': 100, 'no_activity': 240}, {'counts': [5, 2, 0, 0], 'occ_pct': [15, 4, 0, 0], 'status': 'ok'}), ({'interval': 30, 'bins': 2, 'events': [[-15, -13], [-10, -5], [-4, -3], [35, 36], [69, 74], [110, 113]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1], 'occ_pct': [0, 3], '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': 3, 'events': [[7, 344], [378, 688], [724, 764], [781, 821], [836, 1109], [1115, 1117], [1135, 1137], [1138, 1140]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0], 'occ_pct': [94, 100, 86], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 2, 'events': [], 'max_presence': 180, 'no_activity': 60}, {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'}), ({'interval': 30, 'bins': 4, 'events': [[1, 204], [238, 240], [251, 603], [638, 678], [704, 712], [739, 779]], 'max_presence': 100, 'no_activity': 120}, {'counts': [1, 0, 0, 0], 'occ_pct': [96, 100, 100, 100], 'status': 'stuck-on'}), ({'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': [[4, 5]], 'max_presence': 240, 'no_activity': 240}, {'counts': [1, 0, 0, 0, 0], 'occ_pct': [1, 0, 0, 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': 5, 'events': [[-1, 0], [39, 79], [94, 97], [134, 136]], 'max_presence': 240, 'no_activity': 600}, {'counts': [0, 1, 0, 1, 1], 'occ_pct': [0, 70, 63, 10, 6], 'status': 'ok'})], [({'interval': 60, 'bins': 3, 'events': [[-9, -4], [13, 14], [15, 18], [40, 45], [63, 426], [451, 491], [522, 527], [549, 552]], 'max_presence': 180, 'no_activity': 240}, {'counts': [3, 1, 0], 'occ_pct': [15, 95, 100], 'status': 'stuck-on'}), ({'interval': 60, 'bins': 5, 'events': [[-13, -10], [21, 61], [79, 87], [96, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 2, 0, 0, 0], 'occ_pct': [65, 16, 0, 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': 5, 'events': [[3, 8], [14, 17]], 'max_presence': 100, 'no_activity': 240}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [13, 0, 0, 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': 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': 120, 'bins': 2, 'events': [[-13, 27], [55, 400]], 'max_presence': 100, 'no_activity': 60}, {'counts': [1, 0], 'occ_pct': [76, 100], 'status': 'stuck-on'}), ({'interval': 120, 'bins': 5, 'events': [[2, 7], [24, 27]], 'max_presence': 100, 'no_activity': 60}, {'counts': [2, 0, 0, 0, 0], 'occ_pct': [6, 0, 0, 0, 0], 'status': 'ok'})], [({'interval': 30, 'bins': 3, 'events': [[-13, -8], [21, 26], [37, 39], [45, 209], [217, 220], [247, 255], [257, 262], [277, 582]], 'max_presence': 240, 'no_activity': 60}, {'counts': [1, 2, 0], 'occ_pct': [16, 56, 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': 4, 'events': [[-3, 5], [16, 56]], 'max_presence': 100, 'no_activity': 600}, {'counts': [1, 0, 0, 0], 'occ_pct': [75, 0, 0, 0], 'status': 'ok'}), ({'interval': 60, 'bins': 2, 'events': [[48, 53], [4, 12], [134, 136], [92, 97]], 'max_presence': 100, 'no_activity': 600}, {'counts': [2, 1], 'occ_pct': [21, 8], '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': 4, 'events': [[2, 3], [22, 62], [76, 78], [116, 124], [142, 147], [173, 175], [215, 220], [255, 258]], 'max_presence': 100, 'no_activity': 120}, {'counts': [2, 2, 2, 1], 'occ_pct': [65, 13, 18, 8], 'status': 'ok'}), ({'interval': 60, 'bins': 3, 'events': [], 'max_presence': 100, 'no_activity': 60}, {'counts': [0, 0, 0], 'occ_pct': [0, 0, 0], 'status': 'no-activity'})]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| timing oracle 0 | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | {'counts': [1, 1, 2], 'occ_pct': [3, 26, 43], 'status': 'ok'} | Passed |
| timing oracle 1 | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | {'counts': [1, 1, 4, 0, 0], 'occ_pct': [99, 95, 15, 0, 0], 'status': 'stuck-on'} | Passed |
| timing oracle 2 | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | {'counts': [0, 0], 'occ_pct': [0, 0], 'status': 'no-activity'} | Passed |
| timing oracle 3 | {'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 4 | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | {'counts': [2, 0, 0], 'occ_pct': [10, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 5 | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | {'counts': [1, 1, 0, 0], 'occ_pct': [3, 16, 0, 0], 'status': 'ok'} | Passed |
| timing oracle 6 | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | {'counts': [1, 1], 'occ_pct': [8, 6], 'status': 'ok'} | Passed |
| timing oracle 7 | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'stuck-on'} | {'counts': [1, 0, 0], 'occ_pct': [91, 100, 100], 'status': 'stuck-on'} | Passed |
SHA-256 / 8842e42218ccdacee57881741b0df03bbc9acc1d19fdfc2b402902d481a7ad14
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.375170+00:00.
Case digest / b1f1202419fb2f6425fa1375fc793c0ef30475206b72bb730217223ac118afb1