FAILURE MAP
← Case archive

FA-94086 / Shift rostering labor rules / Open access

Shift covering part of a slot counts toward staffing · case 01

A worker leaving halfway through a slot is counted for the whole slot.

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

ROOT CAUSE

Coverage uses interval overlap instead of full containment.

VERIFIED REPAIR

A shift covers a slot only if it starts by the slot start and ends at or after the slot end.

Unsuccessful approach: Requiring only the slot start to be covered still counts early leavers.

Case contract

Shifts [worker, role, start, end], a list of required headcount per slot and a slot length. A shift covers slot k only if it spans the whole slot [k*slot, (k+1)*slot). Coverage is counted in half-heads: trainees 1, staff and supervisors 2; a worker counts once per slot at their best role weight. Return [slot, have, need] (half-heads) for every understaffed slot.

Why this case matters

Coverage checks decide whether a roster meets minimum staffing ratios.

1 / The failure

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

N = 1
observations = []
def solve(shifts, need, slot):
    out = []
    for k, req in enumerate(need):
        a, b = k * slot, (k + 1) * slot
        seen = {}
        for w, role, s, e in shifts:
            if s < b and e > a:
                seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
        have = sum(seen.values())
        if have < 2 * req:
            out.append([k, have, 2 * req])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial slot coverage 1', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 180, 360], ['w4', 'staff', 30, 210], ['w4', 'supervisor', 180, 210]], [3, 1, 0, 2],
    60],
   [[0, 0, 6], [3, 2, 4]]),
  ('partial repair guard 3',
   [[['w4', 'staff', 30, 90], ['w4', 'trainee', 30, 90], ['w1', 'staff', 90, 210], ['w1', 'staff', 90, 150],
     ['w1', 'supervisor', 0, 180], ['w4', 'staff', 180, 270]],
    [0, 0, 0, 2, 3], 60],
   [[3, 2, 4], [4, 0, 6]]),
  ('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
  ('normal control 5',
   [[['w4', 'supervisor', 0, 90], ['w4', 'supervisor', 30, 120], ['w1', 'trainee', 30, 90],
     ['w3', 'staff', 30, 90], ['w3', 'staff', 180, 270], ['w4', 'supervisor', 90, 180]],
    [3, 1, 2, 2, 0], 60],
   [[0, 2, 6], [2, 2, 4], [3, 2, 4]]),
  ('normal control 6',
   [[['w1', 'trainee', 180, 270], ['w1', 'supervisor', 180, 420], ['w3', 'trainee', 180, 240],
     ['w3', 'staff', 60, 150], ['w1', 'staff', 30, 60], ['w3', 'trainee', 120, 150],
     ['w2', 'supervisor', 0, 30]],
    [2, 2, 1, 2], 60],
   [[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]),
  ('normal control 7',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 8', [[['w1', 'staff', 0, 60], ['w1', 'trainee', 60, 240]], [0, 3, 0, 0, 1], 60],
   [[1, 1, 6], [4, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
     ['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
    [2, 1, 3, 3], 60],
   [[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'trainee', 180, 270], ['w3', 'supervisor', 60, 90], ['w2', 'supervisor', 60, 90]], [3, 1, 3, 3],
    60],
   [[0, 0, 6], [1, 0, 2], [2, 0, 6], [3, 1, 6]]),
  ('partial repair guard 3',
   [[['w4', 'supervisor', 60, 150], ['w3', 'staff', 120, 210], ['w4', 'trainee', 180, 360],
     ['w2', 'supervisor', 180, 270], ['w4', 'supervisor', 180, 300], ['w2', 'staff', 60, 150]],
    [0, 1, 3], 60],
   [[2, 2, 6]]),
  ('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('normal control 5',
   [[['w4', 'staff', 60, 300], ['w1', 'supervisor', 120, 360], ['w1', 'staff', 30, 150],
     ['w3', 'staff', 90, 270], ['w2', 'supervisor', 30, 270], ['w3', 'supervisor', 90, 180],
     ['w1', 'supervisor', 30, 150]],
    [2, 0, 3], 60],
   [[0, 0, 4]]),
  ('normal control 6',
   [[['w2', 'staff', 0, 240], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 180, 270],
     ['w3', 'staff', 180, 360], ['w1', 'trainee', 60, 90]],
    [2, 3, 2, 1, 1], 60],
   [[1, 2, 6], [2, 2, 4]]),
  ('normal control 7',
   [[['w2', 'supervisor', 90, 120], ['w2', 'staff', 0, 240], ['w2', 'staff', 0, 30],
     ['w2', 'trainee', 30, 90], ['w4', 'staff', 90, 210], ['w3', 'staff', 90, 270],
     ['w1', 'supervisor', 180, 240]],
    [1, 2, 1, 1], 60],
   [[1, 2, 4]]),
  ('normal control 8',
   [[['w3', 'supervisor', 120, 180], ['w2', 'staff', 90, 330], ['w2', 'trainee', 120, 150],
     ['w3', 'trainee', 0, 90], ['w3', 'trainee', 0, 30], ['w3', 'staff', 90, 210],
     ['w4', 'staff', 180, 210]],
    [0, 1, 0, 1], 60],
   [[1, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
     ['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
    [1, 3, 3], 60],
   [[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'staff', 60, 300], ['w1', 'staff', 180, 270], ['w1', 'trainee', 60, 240],
     ['w1', 'trainee', 180, 210], ['w4', 'staff', 60, 90], ['w4', 'staff', 30, 90]],
    [1, 1, 3, 0, 2], 60],
   [[0, 0, 2], [2, 3, 6], [4, 2, 4]]),
  ('partial repair guard 3',
   [[['w2', 'trainee', 90, 330], ['w4', 'staff', 0, 30], ['w2', 'trainee', 30, 150],
     ['w3', 'trainee', 90, 150]],
    [1, 0, 0], 60],
   [[0, 0, 2]]),
  ('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
  ('normal control 5',
   [[['w2', 'staff', 0, 90], ['w1', 'supervisor', 0, 60], ['w4', 'trainee', 60, 150],
     ['w2', 'staff', 120, 180], ['w2', 'staff', 60, 300], ['w1', 'staff', 120, 240]],
    [0, 1, 0, 0, 2], 60],
   [[4, 2, 4]]),
  ('normal control 6',
   [[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
   [[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
  ('normal control 7',
   [[['w4', 'staff', 120, 360], ['w3', 'staff', 30, 270], ['w1', 'supervisor', 120, 210],
     ['w1', 'trainee', 90, 150], ['w1', 'staff', 120, 150], ['w4', 'staff', 60, 240]],
    [0, 3, 3, 3, 2], 60],
   [[1, 4, 6], [3, 4, 6], [4, 2, 4]]),
  ('normal control 8',
   [[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
     ['w1', 'staff', 0, 90]],
    [0, 1, 1, 2], 60],
   [[3, 0, 4]])],
 [('regression: partial slot coverage 1',
   [[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
     ['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
    [1, 3, 2, 3, 3, 2], 60],
   [[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
     ['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
    [3, 3, 1, 2, 3, 0], 60],
   [[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
  ('partial repair guard 3',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
  ('normal control 5',
   [[['w2', 'supervisor', 30, 90], ['w3', 'staff', 90, 120], ['w3', 'supervisor', 120, 210],
     ['w2', 'staff', 60, 150], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150], ['w3', 'staff', 180, 240]],
    [3, 0, 2, 1], 60],
   [[0, 2, 6]]),
  ('normal control 6',
   [[['w2', 'staff', 120, 300], ['w2', 'supervisor', 60, 300], ['w2', 'staff', 90, 120],
     ['w2', 'staff', 60, 240], ['w2', 'staff', 60, 90], ['w4', 'supervisor', 120, 180],
     ['w4', 'supervisor', 120, 180]],
    [0, 0, 1, 0, 3], 60],
   [[4, 2, 6]]),
  ('normal control 7',
   [[['w3', 'staff', 120, 240], ['w1', 'staff', 180, 270], ['w4', 'supervisor', 180, 360],
     ['w2', 'trainee', 60, 300], ['w4', 'staff', 30, 120]],
    [2, 2, 1, 1, 2], 60],
   [[0, 0, 4], [1, 3, 4], [4, 3, 4]]),
  ('normal control 8',
   [[['w2', 'staff', 90, 180], ['w1', 'trainee', 30, 60], ['w2', 'trainee', 30, 120],
     ['w4', 'trainee', 90, 150]],
    [3, 0, 3], 60],
   [[0, 0, 6], [2, 2, 6]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
     ['w1', 'staff', 120, 240]],
    [3, 1, 0, 2, 0], 60],
   [[0, 0, 6], [1, 1, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('partial repair guard 3', [[['w2', 'supervisor', 0, 60], ['w4', 'trainee', 90, 210]], [3, 0, 2, 2], 60],
   [[0, 2, 6], [2, 1, 4], [3, 0, 4]]),
  ('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
  ('normal control 5', [[['w3', 'staff', 120, 300], ['w2', 'staff', 30, 120]], [3, 0, 3, 1, 3], 60],
   [[0, 0, 6], [2, 2, 6], [4, 2, 6]]),
  ('normal control 6',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 7',
   [[['w1', 'staff', 180, 210], ['w1', 'supervisor', 0, 120], ['w2', 'staff', 30, 60],
     ['w4', 'supervisor', 180, 240], ['w1', 'staff', 180, 240], ['w2', 'staff', 30, 150],
     ['w3', 'supervisor', 0, 30]],
    [0, 0, 2, 2, 3, 2], 60],
   [[2, 0, 4], [4, 0, 6], [5, 0, 4]]),
  ('normal control 8', [[['w3', 'staff', 60, 240], ['w1', 'supervisor', 30, 270]], [2, 0, 3], 60],
   [[0, 0, 4], [2, 4, 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
regression: partial slot coverage 1[][[0, 0, 2]]Failed
regression variant: partial slot coverage 2[[0, 2, 6]][[0, 0, 6], [3, 2, 4]]Failed
partial repair guard 3[[4, 2, 6]][[3, 2, 4], [4, 0, 6]]Failed
boundary control 4[[0, 2, 4]][[0, 2, 4]]Passed
normal control 5[[0, 5, 6], [2, 2, 4], [3, 2, 4]][[0, 2, 6], [2, 2, 4], [3, 2, 4]]Failed
normal control 6[[1, 2, 4], [3, 3, 4]][[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]Failed
normal control 7[[2, 1, 4]][[2, 1, 4]]Passed
normal control 8[[1, 1, 6], [4, 0, 2]][[1, 1, 6], [4, 0, 2]]Passed

SHA-256 / ce9f93b75b9c9da64d1bc3160e79a260306ae0ef58509a8c80e75c952f1a42fa

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shifts, need, slot):
    out = []
    for k, req in enumerate(need):
        a, b = k * slot, (k + 1) * slot
        seen = {}
        for w, role, s, e in shifts:
            if s <= a and e > a:
                seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
        have = sum(seen.values())
        if have < 2 * req:
            out.append([k, have, 2 * req])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial slot coverage 1', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 180, 360], ['w4', 'staff', 30, 210], ['w4', 'supervisor', 180, 210]], [3, 1, 0, 2],
    60],
   [[0, 0, 6], [3, 2, 4]]),
  ('partial repair guard 3',
   [[['w4', 'staff', 30, 90], ['w4', 'trainee', 30, 90], ['w1', 'staff', 90, 210], ['w1', 'staff', 90, 150],
     ['w1', 'supervisor', 0, 180], ['w4', 'staff', 180, 270]],
    [0, 0, 0, 2, 3], 60],
   [[3, 2, 4], [4, 0, 6]]),
  ('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
  ('normal control 5',
   [[['w4', 'supervisor', 0, 90], ['w4', 'supervisor', 30, 120], ['w1', 'trainee', 30, 90],
     ['w3', 'staff', 30, 90], ['w3', 'staff', 180, 270], ['w4', 'supervisor', 90, 180]],
    [3, 1, 2, 2, 0], 60],
   [[0, 2, 6], [2, 2, 4], [3, 2, 4]]),
  ('normal control 6',
   [[['w1', 'trainee', 180, 270], ['w1', 'supervisor', 180, 420], ['w3', 'trainee', 180, 240],
     ['w3', 'staff', 60, 150], ['w1', 'staff', 30, 60], ['w3', 'trainee', 120, 150],
     ['w2', 'supervisor', 0, 30]],
    [2, 2, 1, 2], 60],
   [[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]),
  ('normal control 7',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 8', [[['w1', 'staff', 0, 60], ['w1', 'trainee', 60, 240]], [0, 3, 0, 0, 1], 60],
   [[1, 1, 6], [4, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
     ['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
    [2, 1, 3, 3], 60],
   [[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'trainee', 180, 270], ['w3', 'supervisor', 60, 90], ['w2', 'supervisor', 60, 90]], [3, 1, 3, 3],
    60],
   [[0, 0, 6], [1, 0, 2], [2, 0, 6], [3, 1, 6]]),
  ('partial repair guard 3',
   [[['w4', 'supervisor', 60, 150], ['w3', 'staff', 120, 210], ['w4', 'trainee', 180, 360],
     ['w2', 'supervisor', 180, 270], ['w4', 'supervisor', 180, 300], ['w2', 'staff', 60, 150]],
    [0, 1, 3], 60],
   [[2, 2, 6]]),
  ('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('normal control 5',
   [[['w4', 'staff', 60, 300], ['w1', 'supervisor', 120, 360], ['w1', 'staff', 30, 150],
     ['w3', 'staff', 90, 270], ['w2', 'supervisor', 30, 270], ['w3', 'supervisor', 90, 180],
     ['w1', 'supervisor', 30, 150]],
    [2, 0, 3], 60],
   [[0, 0, 4]]),
  ('normal control 6',
   [[['w2', 'staff', 0, 240], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 180, 270],
     ['w3', 'staff', 180, 360], ['w1', 'trainee', 60, 90]],
    [2, 3, 2, 1, 1], 60],
   [[1, 2, 6], [2, 2, 4]]),
  ('normal control 7',
   [[['w2', 'supervisor', 90, 120], ['w2', 'staff', 0, 240], ['w2', 'staff', 0, 30],
     ['w2', 'trainee', 30, 90], ['w4', 'staff', 90, 210], ['w3', 'staff', 90, 270],
     ['w1', 'supervisor', 180, 240]],
    [1, 2, 1, 1], 60],
   [[1, 2, 4]]),
  ('normal control 8',
   [[['w3', 'supervisor', 120, 180], ['w2', 'staff', 90, 330], ['w2', 'trainee', 120, 150],
     ['w3', 'trainee', 0, 90], ['w3', 'trainee', 0, 30], ['w3', 'staff', 90, 210],
     ['w4', 'staff', 180, 210]],
    [0, 1, 0, 1], 60],
   [[1, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
     ['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
    [1, 3, 3], 60],
   [[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'staff', 60, 300], ['w1', 'staff', 180, 270], ['w1', 'trainee', 60, 240],
     ['w1', 'trainee', 180, 210], ['w4', 'staff', 60, 90], ['w4', 'staff', 30, 90]],
    [1, 1, 3, 0, 2], 60],
   [[0, 0, 2], [2, 3, 6], [4, 2, 4]]),
  ('partial repair guard 3',
   [[['w2', 'trainee', 90, 330], ['w4', 'staff', 0, 30], ['w2', 'trainee', 30, 150],
     ['w3', 'trainee', 90, 150]],
    [1, 0, 0], 60],
   [[0, 0, 2]]),
  ('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
  ('normal control 5',
   [[['w2', 'staff', 0, 90], ['w1', 'supervisor', 0, 60], ['w4', 'trainee', 60, 150],
     ['w2', 'staff', 120, 180], ['w2', 'staff', 60, 300], ['w1', 'staff', 120, 240]],
    [0, 1, 0, 0, 2], 60],
   [[4, 2, 4]]),
  ('normal control 6',
   [[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
   [[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
  ('normal control 7',
   [[['w4', 'staff', 120, 360], ['w3', 'staff', 30, 270], ['w1', 'supervisor', 120, 210],
     ['w1', 'trainee', 90, 150], ['w1', 'staff', 120, 150], ['w4', 'staff', 60, 240]],
    [0, 3, 3, 3, 2], 60],
   [[1, 4, 6], [3, 4, 6], [4, 2, 4]]),
  ('normal control 8',
   [[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
     ['w1', 'staff', 0, 90]],
    [0, 1, 1, 2], 60],
   [[3, 0, 4]])],
 [('regression: partial slot coverage 1',
   [[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
     ['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
    [1, 3, 2, 3, 3, 2], 60],
   [[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
     ['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
    [3, 3, 1, 2, 3, 0], 60],
   [[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
  ('partial repair guard 3',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
  ('normal control 5',
   [[['w2', 'supervisor', 30, 90], ['w3', 'staff', 90, 120], ['w3', 'supervisor', 120, 210],
     ['w2', 'staff', 60, 150], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150], ['w3', 'staff', 180, 240]],
    [3, 0, 2, 1], 60],
   [[0, 2, 6]]),
  ('normal control 6',
   [[['w2', 'staff', 120, 300], ['w2', 'supervisor', 60, 300], ['w2', 'staff', 90, 120],
     ['w2', 'staff', 60, 240], ['w2', 'staff', 60, 90], ['w4', 'supervisor', 120, 180],
     ['w4', 'supervisor', 120, 180]],
    [0, 0, 1, 0, 3], 60],
   [[4, 2, 6]]),
  ('normal control 7',
   [[['w3', 'staff', 120, 240], ['w1', 'staff', 180, 270], ['w4', 'supervisor', 180, 360],
     ['w2', 'trainee', 60, 300], ['w4', 'staff', 30, 120]],
    [2, 2, 1, 1, 2], 60],
   [[0, 0, 4], [1, 3, 4], [4, 3, 4]]),
  ('normal control 8',
   [[['w2', 'staff', 90, 180], ['w1', 'trainee', 30, 60], ['w2', 'trainee', 30, 120],
     ['w4', 'trainee', 90, 150]],
    [3, 0, 3], 60],
   [[0, 0, 6], [2, 2, 6]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
     ['w1', 'staff', 120, 240]],
    [3, 1, 0, 2, 0], 60],
   [[0, 0, 6], [1, 1, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('partial repair guard 3', [[['w2', 'supervisor', 0, 60], ['w4', 'trainee', 90, 210]], [3, 0, 2, 2], 60],
   [[0, 2, 6], [2, 1, 4], [3, 0, 4]]),
  ('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
  ('normal control 5', [[['w3', 'staff', 120, 300], ['w2', 'staff', 30, 120]], [3, 0, 3, 1, 3], 60],
   [[0, 0, 6], [2, 2, 6], [4, 2, 6]]),
  ('normal control 6',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 7',
   [[['w1', 'staff', 180, 210], ['w1', 'supervisor', 0, 120], ['w2', 'staff', 30, 60],
     ['w4', 'supervisor', 180, 240], ['w1', 'staff', 180, 240], ['w2', 'staff', 30, 150],
     ['w3', 'supervisor', 0, 30]],
    [0, 0, 2, 2, 3, 2], 60],
   [[2, 0, 4], [4, 0, 6], [5, 0, 4]]),
  ('normal control 8', [[['w3', 'staff', 60, 240], ['w1', 'supervisor', 30, 270]], [2, 0, 3], 60],
   [[0, 0, 4], [2, 4, 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
regression: partial slot coverage 1[[0, 0, 2]][[0, 0, 2]]Passed
regression variant: partial slot coverage 2[[0, 0, 6]][[0, 0, 6], [3, 2, 4]]Failed
partial repair guard 3[[4, 2, 6]][[3, 2, 4], [4, 0, 6]]Failed
boundary control 4[[0, 2, 4]][[0, 2, 4]]Passed
normal control 5[[0, 2, 6], [2, 2, 4], [3, 2, 4]][[0, 2, 6], [2, 2, 4], [3, 2, 4]]Passed
normal control 6[[0, 2, 4], [1, 2, 4], [3, 3, 4]][[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]Failed
normal control 7[[2, 1, 4]][[2, 1, 4]]Passed
normal control 8[[1, 1, 6], [4, 0, 2]][[1, 1, 6], [4, 0, 2]]Passed

SHA-256 / 49fcec64625d00b43e057c1d321fe49a05e559e509f5e57af02fa0321f00a7e9

3 / The verified repair

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

N = 1
observations = []
def solve(shifts, need, slot):
    out = []
    for k, req in enumerate(need):
        a, b = k * slot, (k + 1) * slot
        seen = {}
        for w, role, s, e in shifts:
            if s <= a and e >= b:
                seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
        have = sum(seen.values())
        if have < 2 * req:
            out.append([k, have, 2 * req])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: partial slot coverage 1', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 180, 360], ['w4', 'staff', 30, 210], ['w4', 'supervisor', 180, 210]], [3, 1, 0, 2],
    60],
   [[0, 0, 6], [3, 2, 4]]),
  ('partial repair guard 3',
   [[['w4', 'staff', 30, 90], ['w4', 'trainee', 30, 90], ['w1', 'staff', 90, 210], ['w1', 'staff', 90, 150],
     ['w1', 'supervisor', 0, 180], ['w4', 'staff', 180, 270]],
    [0, 0, 0, 2, 3], 60],
   [[3, 2, 4], [4, 0, 6]]),
  ('boundary control 4', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60], [[0, 2, 4]]),
  ('normal control 5',
   [[['w4', 'supervisor', 0, 90], ['w4', 'supervisor', 30, 120], ['w1', 'trainee', 30, 90],
     ['w3', 'staff', 30, 90], ['w3', 'staff', 180, 270], ['w4', 'supervisor', 90, 180]],
    [3, 1, 2, 2, 0], 60],
   [[0, 2, 6], [2, 2, 4], [3, 2, 4]]),
  ('normal control 6',
   [[['w1', 'trainee', 180, 270], ['w1', 'supervisor', 180, 420], ['w3', 'trainee', 180, 240],
     ['w3', 'staff', 60, 150], ['w1', 'staff', 30, 60], ['w3', 'trainee', 120, 150],
     ['w2', 'supervisor', 0, 30]],
    [2, 2, 1, 2], 60],
   [[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]),
  ('normal control 7',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 8', [[['w1', 'staff', 0, 60], ['w1', 'trainee', 60, 240]], [0, 3, 0, 0, 1], 60],
   [[1, 1, 6], [4, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'supervisor', 120, 360], ['w3', 'supervisor', 30, 270], ['w2', 'trainee', 120, 180],
     ['w2', 'trainee', 0, 120], ['w2', 'trainee', 180, 420], ['w3', 'trainee', 30, 210]],
    [2, 1, 3, 3], 60],
   [[0, 1, 4], [2, 5, 6], [3, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'trainee', 180, 270], ['w3', 'supervisor', 60, 90], ['w2', 'supervisor', 60, 90]], [3, 1, 3, 3],
    60],
   [[0, 0, 6], [1, 0, 2], [2, 0, 6], [3, 1, 6]]),
  ('partial repair guard 3',
   [[['w4', 'supervisor', 60, 150], ['w3', 'staff', 120, 210], ['w4', 'trainee', 180, 360],
     ['w2', 'supervisor', 180, 270], ['w4', 'supervisor', 180, 300], ['w2', 'staff', 60, 150]],
    [0, 1, 3], 60],
   [[2, 2, 6]]),
  ('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
  ('normal control 5',
   [[['w4', 'staff', 60, 300], ['w1', 'supervisor', 120, 360], ['w1', 'staff', 30, 150],
     ['w3', 'staff', 90, 270], ['w2', 'supervisor', 30, 270], ['w3', 'supervisor', 90, 180],
     ['w1', 'supervisor', 30, 150]],
    [2, 0, 3], 60],
   [[0, 0, 4]]),
  ('normal control 6',
   [[['w2', 'staff', 0, 240], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 180, 270],
     ['w3', 'staff', 180, 360], ['w1', 'trainee', 60, 90]],
    [2, 3, 2, 1, 1], 60],
   [[1, 2, 6], [2, 2, 4]]),
  ('normal control 7',
   [[['w2', 'supervisor', 90, 120], ['w2', 'staff', 0, 240], ['w2', 'staff', 0, 30],
     ['w2', 'trainee', 30, 90], ['w4', 'staff', 90, 210], ['w3', 'staff', 90, 270],
     ['w1', 'supervisor', 180, 240]],
    [1, 2, 1, 1], 60],
   [[1, 2, 4]]),
  ('normal control 8',
   [[['w3', 'supervisor', 120, 180], ['w2', 'staff', 90, 330], ['w2', 'trainee', 120, 150],
     ['w3', 'trainee', 0, 90], ['w3', 'trainee', 0, 30], ['w3', 'staff', 90, 210],
     ['w4', 'staff', 180, 210]],
    [0, 1, 0, 1], 60],
   [[1, 0, 2]])],
 [('regression: partial slot coverage 1',
   [[['w3', 'staff', 120, 240], ['w4', 'supervisor', 90, 330], ['w2', 'staff', 60, 150],
     ['w1', 'staff', 180, 270], ['w1', 'trainee', 90, 180], ['w1', 'staff', 30, 90]],
    [1, 3, 3], 60],
   [[0, 0, 2], [1, 2, 6], [2, 5, 6]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'staff', 60, 300], ['w1', 'staff', 180, 270], ['w1', 'trainee', 60, 240],
     ['w1', 'trainee', 180, 210], ['w4', 'staff', 60, 90], ['w4', 'staff', 30, 90]],
    [1, 1, 3, 0, 2], 60],
   [[0, 0, 2], [2, 3, 6], [4, 2, 4]]),
  ('partial repair guard 3',
   [[['w2', 'trainee', 90, 330], ['w4', 'staff', 0, 30], ['w2', 'trainee', 30, 150],
     ['w3', 'trainee', 90, 150]],
    [1, 0, 0], 60],
   [[0, 0, 2]]),
  ('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
  ('normal control 5',
   [[['w2', 'staff', 0, 90], ['w1', 'supervisor', 0, 60], ['w4', 'trainee', 60, 150],
     ['w2', 'staff', 120, 180], ['w2', 'staff', 60, 300], ['w1', 'staff', 120, 240]],
    [0, 1, 0, 0, 2], 60],
   [[4, 2, 4]]),
  ('normal control 6',
   [[['w4', 'trainee', 180, 270], ['w1', 'supervisor', 90, 180], ['w3', 'staff', 0, 90]], [2, 2, 3], 60],
   [[0, 2, 4], [1, 0, 4], [2, 2, 6]]),
  ('normal control 7',
   [[['w4', 'staff', 120, 360], ['w3', 'staff', 30, 270], ['w1', 'supervisor', 120, 210],
     ['w1', 'trainee', 90, 150], ['w1', 'staff', 120, 150], ['w4', 'staff', 60, 240]],
    [0, 3, 3, 3, 2], 60],
   [[1, 4, 6], [3, 4, 6], [4, 2, 4]]),
  ('normal control 8',
   [[['w3', 'staff', 30, 210], ['w4', 'trainee', 30, 210], ['w3', 'trainee', 90, 180],
     ['w1', 'staff', 0, 90]],
    [0, 1, 1, 2], 60],
   [[3, 0, 4]])],
 [('regression: partial slot coverage 1',
   [[['w2', 'trainee', 0, 90], ['w3', 'trainee', 120, 240], ['w4', 'staff', 0, 90],
     ['w3', 'supervisor', 0, 180], ['w3', 'supervisor', 120, 180], ['w4', 'staff', 120, 360]],
    [1, 3, 2, 3, 3, 2], 60],
   [[1, 2, 6], [3, 3, 6], [4, 2, 6], [5, 2, 4]]),
  ('regression variant: partial slot coverage 2',
   [[['w2', 'supervisor', 120, 150], ['w2', 'staff', 60, 150], ['w3', 'supervisor', 180, 270],
     ['w4', 'trainee', 90, 120], ['w2', 'trainee', 60, 150], ['w1', 'supervisor', 30, 210]],
    [3, 3, 1, 2, 3, 0], 60],
   [[0, 0, 6], [1, 4, 6], [3, 2, 4], [4, 0, 6]]),
  ('partial repair guard 3',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
  ('normal control 5',
   [[['w2', 'supervisor', 30, 90], ['w3', 'staff', 90, 120], ['w3', 'supervisor', 120, 210],
     ['w2', 'staff', 60, 150], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150], ['w3', 'staff', 180, 240]],
    [3, 0, 2, 1], 60],
   [[0, 2, 6]]),
  ('normal control 6',
   [[['w2', 'staff', 120, 300], ['w2', 'supervisor', 60, 300], ['w2', 'staff', 90, 120],
     ['w2', 'staff', 60, 240], ['w2', 'staff', 60, 90], ['w4', 'supervisor', 120, 180],
     ['w4', 'supervisor', 120, 180]],
    [0, 0, 1, 0, 3], 60],
   [[4, 2, 6]]),
  ('normal control 7',
   [[['w3', 'staff', 120, 240], ['w1', 'staff', 180, 270], ['w4', 'supervisor', 180, 360],
     ['w2', 'trainee', 60, 300], ['w4', 'staff', 30, 120]],
    [2, 2, 1, 1, 2], 60],
   [[0, 0, 4], [1, 3, 4], [4, 3, 4]]),
  ('normal control 8',
   [[['w2', 'staff', 90, 180], ['w1', 'trainee', 30, 60], ['w2', 'trainee', 30, 120],
     ['w4', 'trainee', 90, 150]],
    [3, 0, 3], 60],
   [[0, 0, 6], [2, 2, 6]])],
 [('regression: partial slot coverage 1',
   [[['w4', 'trainee', 60, 240], ['w4', 'staff', 90, 120], ['w4', 'staff', 120, 240],
     ['w1', 'staff', 120, 240]],
    [3, 1, 0, 2, 0], 60],
   [[0, 0, 6], [1, 1, 2]]),
  ('regression variant: partial slot coverage 2',
   [[['w1', 'staff', 0, 240], ['w2', 'supervisor', 90, 330]], [3, 1, 1, 3, 2, 3], 60],
   [[0, 2, 6], [3, 4, 6], [4, 2, 4], [5, 0, 6]]),
  ('partial repair guard 3', [[['w2', 'supervisor', 0, 60], ['w4', 'trainee', 90, 210]], [3, 0, 2, 2], 60],
   [[0, 2, 6], [2, 1, 4], [3, 0, 4]]),
  ('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
  ('normal control 5', [[['w3', 'staff', 120, 300], ['w2', 'staff', 30, 120]], [3, 0, 3, 1, 3], 60],
   [[0, 0, 6], [2, 2, 6], [4, 2, 6]]),
  ('normal control 6',
   [[['w3', 'supervisor', 30, 60], ['w3', 'trainee', 90, 210], ['w4', 'trainee', 0, 120],
     ['w4', 'trainee', 90, 120]],
    [0, 0, 2], 60],
   [[2, 1, 4]]),
  ('normal control 7',
   [[['w1', 'staff', 180, 210], ['w1', 'supervisor', 0, 120], ['w2', 'staff', 30, 60],
     ['w4', 'supervisor', 180, 240], ['w1', 'staff', 180, 240], ['w2', 'staff', 30, 150],
     ['w3', 'supervisor', 0, 30]],
    [0, 0, 2, 2, 3, 2], 60],
   [[2, 0, 4], [4, 0, 6], [5, 0, 4]]),
  ('normal control 8', [[['w3', 'staff', 60, 240], ['w1', 'supervisor', 30, 270]], [2, 0, 3], 60],
   [[0, 0, 4], [2, 4, 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
regression: partial slot coverage 1[[0, 0, 2]][[0, 0, 2]]Passed
regression variant: partial slot coverage 2[[0, 0, 6], [3, 2, 4]][[0, 0, 6], [3, 2, 4]]Passed
partial repair guard 3[[3, 2, 4], [4, 0, 6]][[3, 2, 4], [4, 0, 6]]Passed
boundary control 4[[0, 2, 4]][[0, 2, 4]]Passed
normal control 5[[0, 2, 6], [2, 2, 4], [3, 2, 4]][[0, 2, 6], [2, 2, 4], [3, 2, 4]]Passed
normal control 6[[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]][[0, 0, 4], [1, 2, 4], [2, 0, 2], [3, 3, 4]]Passed
normal control 7[[2, 1, 4]][[2, 1, 4]]Passed
normal control 8[[1, 1, 6], [4, 0, 2]][[1, 1, 6], [4, 0, 2]]Passed

SHA-256 / 7ffa32b1e83c1bf9cc477d47c240b4bb4cbf4eea77d9f1da3dc2643cbb58b5bc

Verification & scope

Stipulated toy labor rule for a bounded roster model; it is not legal advice and does not claim conformance with any jurisdiction, award, or collective agreement. 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:52:01.047164+00:00.

Case digest / ac7f19ddbf376c54f5e35f853495c5cf118e994109b29386631f5f3747abf145