FAILURE MAP
← Case archive

FA-93071 / EV charging session scheduling / Open access

Round-robin port rotation: finish slot index · case 01

Reported finish times are one slot earlier than the last charging slot ends.

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

ROOT CAUSE

The finish records the index of the last charging slot instead of the slot after it.

VERIFIED REPAIR

Record t + 1 as the finish.

Unsuccessful approach: Adding the quantum reports finishes long after the port was released.

Case contract

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

Why this case matters

Depot, workplace and public EV chargers schedule sessions against prices, circuit limits and departure deadlines; a wrong decision silently strands a driver or overloads a feeder.

1 / The failure

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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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
boundary: vehicle needing nothing[[['B'], ['B'], []], [['A', 0], ['B', 1]]][[['B'], ['B'], []], [['A', 0], ['B', 2]]]Failed
boundary: finishes exactly at quantum end[[['A'], ['A'], ['B'], ['B'], []], [['A', 1], ['B', 3]]][[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]Failed
boundary: more ports than vehicles[[['A'], ['A'], ['A'], []], [['A', 2]]][[['A'], ['A'], ['A'], []], [['A', 3]]]Failed
regression: finish slot index[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 1], ['V1', 0], ['V2', 2]]][[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]Failed
regression: finish slot index (partial repair)[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 2]]][[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]]Failed
control 1[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 0], ['V1', None], ['V2', None], ['V3', 6], ['V4', None], ['V5', None]]][[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]Failed
control 2[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 5]]][[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]Failed

SHA-256 / 7505f2ace54a5ab0f801bb345af8261e2a9da2214acf77663820c30f23ce2e73

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + quantum
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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
boundary: vehicle needing nothing[[['B'], ['B'], []], [['A', 0], ['B', 2]]][[['B'], ['B'], []], [['A', 0], ['B', 2]]]Passed
boundary: finishes exactly at quantum end[[['A'], ['A'], ['B'], ['B'], []], [['A', 3], ['B', 5]]][[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]Failed
boundary: more ports than vehicles[[['A'], ['A'], ['A'], []], [['A', 3]]][[['A'], ['A'], ['A'], []], [['A', 3]]]Passed
regression: finish slot index[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]][[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]Passed
regression: finish slot index (partial repair)[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 5], ['V1', 3], ['V2', 5]]][[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]]Failed
control 1[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 2], ['V1', None], ['V2', None], ['V3', 8], ['V4', None], ['V5', None]]][[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]Failed
control 2[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 7]]][[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]Failed

SHA-256 / f0dc0114482c235410b7e264dc3c218d9e94f93e232c5cb264052e24e25edc59

3 / The verified repair

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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (0 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 3], ['V1', 1], ['V2', 3]], 3, 10, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []],
    [['V0', 3], ['V1', 1], ['V2', 3]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 5], ['V1', 2], ['V2', 5], ['V3', 1], ['V4', 2], ['V5', 5]], 1, 12, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V4'], ['V4'],
     ['V5']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', 9], ['V4', 11], ['V5', None]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 4], ['V1', 2], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 6]], 1, 10, 3],
   [[['V0'], ['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2'], ['V3'], ['V3']],
    [['V0', None], ['V1', 5], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['regression: finish slot index (partial repair)', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index', [[['V0', 3]], 3, 8, 2],
   [[['V0'], ['V0'], ['V0'], [], [], [], [], []], [['V0', 3]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 4], ['V1', 6], ['V2', 2], ['V3', 2], ['V4', 5]], 3, 5, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V3'], ['V0', 'V3', 'V4'], ['V1', 'V4']],
    [['V0', 4], ['V1', None], ['V2', 2], ['V3', 4], ['V4', None]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: finish slot index',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: finish slot index (partial repair)',
   [[['V0', 3], ['V1', 1], ['V2', 1], ['V3', 1], ['V4', 5], ['V5', 2]], 1, 3, 2],
   [[['V0'], ['V0'], ['V1']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
for label, args, expected in fixtures[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
boundary: vehicle needing nothing[[['B'], ['B'], []], [['A', 0], ['B', 2]]][[['B'], ['B'], []], [['A', 0], ['B', 2]]]Passed
boundary: finishes exactly at quantum end[[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]][[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]Passed
boundary: more ports than vehicles[[['A'], ['A'], ['A'], []], [['A', 3]]][[['A'], ['A'], ['A'], []], [['A', 3]]]Passed
regression: finish slot index[[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]][[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]Passed
regression: finish slot index (partial repair)[[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]][[['V0', 'V1', 'V2'], ['V0', 'V2'], ['V0', 'V2'], [], [], [], [], [], [], []], [['V0', 3], ['V1', 1], ['V2', 3]]]Passed
control 1[[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]][[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']], [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]Passed
control 2[[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]][[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]Passed

SHA-256 / 43ffc850f89a63b4c00a073f7f909ad5ce26f2e62079977d6d585fe116a712d3

Verification & scope

Deterministic stipulated toy contract for teaching; no claim of conformance with any standard, vendor protocol or production controller. 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:51:51.722761+00:00.

Case digest / e284d160d371fd89fdfd6203bb64e0639177bd0904702f1c39440435066bd9c7