FA-94101 / Shift rostering labor rules / Open access
Half-head coverage compared against whole-head requirement · case 01
Slots with half the required staff pass.
ROOT CAUSE
The half-head total is compared with the requirement in whole heads.
VERIFIED REPAIR
Compare against twice the required headcount.
Unsuccessful approach: Rounding a single trainee up to a whole head still accepts under-coverage.
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 <= a and e >= b:
seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
have = sum(seen.values())
if have < 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: half head comparison 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: half head comparison 2',
[[['w4', 'staff', 120, 360], ['w2', 'supervisor', 60, 150], ['w4', 'staff', 0, 180],
['w3', 'staff', 180, 270]],
[2, 2, 0, 2, 1], 60],
[[0, 2, 4]]),
('partial repair guard 3', [[['w2', 'trainee', 60, 120], ['w1', 'staff', 120, 300]], [0, 1, 3, 1, 1], 60],
[[1, 1, 2], [2, 2, 6]]),
('normal control 4',
[[['w3', 'supervisor', 60, 150], ['w4', 'staff', 60, 300], ['w1', 'staff', 90, 210]], [0, 0, 0, 3, 0], 60],
[[3, 2, 6]]),
('normal control 5',
[[['w2', 'supervisor', 0, 120], ['w1', 'supervisor', 60, 90], ['w1', 'supervisor', 0, 120],
['w2', 'trainee', 90, 210]],
[0, 3, 1, 3], 60],
[[1, 4, 6], [2, 1, 2], [3, 0, 6]]),
('normal control 6',
[[['w1', 'trainee', 90, 180], ['w3', 'staff', 90, 270], ['w3', 'staff', 30, 60], ['w3', 'trainee', 0, 240],
['w3', 'supervisor', 60, 90], ['w3', 'trainee', 30, 150]],
[1, 0, 0, 0, 3], 60],
[[0, 1, 2], [4, 0, 6]]),
('normal control 7',
[[['w3', 'trainee', 90, 210], ['w4', 'staff', 90, 150], ['w3', 'trainee', 60, 300],
['w3', 'staff', 90, 120], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150],
['w4', 'supervisor', 30, 210]],
[3, 3, 2, 0], 60],
[[0, 2, 6], [1, 3, 6], [2, 3, 4]]),
('normal control 8',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]])],
[('regression: half head comparison 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: half head comparison 2',
[[['w1', 'trainee', 120, 360], ['w3', 'staff', 60, 180], ['w3', 'supervisor', 30, 60]], [0, 3, 2], 60],
[[1, 2, 6], [2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5', [[['w1', 'staff', 60, 150], ['w1', 'staff', 0, 120]], [0, 3, 3, 3, 1, 2], 60],
[[1, 2, 6], [2, 0, 6], [3, 0, 6], [4, 0, 2], [5, 0, 4]]),
('normal control 6',
[[['w1', 'supervisor', 90, 180], ['w1', 'staff', 30, 120], ['w2', 'staff', 0, 180]], [0, 1, 0, 1, 0, 1],
60],
[[3, 0, 2], [5, 0, 2]]),
('normal control 7',
[[['w2', 'staff', 0, 90], ['w4', 'staff', 180, 270], ['w3', 'trainee', 180, 210],
['w3', 'staff', 180, 360], ['w2', 'staff', 0, 90], ['w2', 'staff', 90, 180],
['w1', 'trainee', 120, 300]],
[1, 0, 1], 60],
[]),
('normal control 8',
[[['w2', 'supervisor', 180, 240], ['w2', 'staff', 0, 30], ['w2', 'staff', 120, 180],
['w2', 'trainee', 180, 420], ['w2', 'supervisor', 180, 240], ['w4', 'staff', 30, 150]],
[2, 0, 1, 3], 60],
[[0, 0, 4], [3, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w3', 'staff', 0, 240], ['w1', 'supervisor', 180, 270], ['w1', 'trainee', 120, 240]], [1, 1, 2, 0], 60],
[[2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5', [[['w1', 'trainee', 30, 90], ['w1', 'supervisor', 30, 210]], [0, 0, 3, 2, 1], 60],
[[2, 2, 6], [3, 0, 4], [4, 0, 2]]),
('normal control 6',
[[['w2', 'staff', 60, 90], ['w2', 'supervisor', 180, 420], ['w2', 'staff', 0, 30],
['w4', 'staff', 120, 300], ['w3', 'trainee', 90, 150], ['w3', 'staff', 180, 300]],
[3, 2, 1, 2, 0], 60],
[[0, 0, 6], [1, 0, 4]]),
('normal control 7',
[[['w3', 'trainee', 0, 240], ['w1', 'supervisor', 0, 90], ['w2', 'supervisor', 30, 120],
['w3', 'supervisor', 0, 120], ['w4', 'staff', 0, 120]],
[1, 1, 3], 60],
[[2, 1, 6]]),
('normal control 8',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w1', 'staff', 0, 180], ['w3', 'staff', 120, 180], ['w2', 'staff', 0, 90]], [0, 0, 0], 60], []),
('normal control 8', [[['w4', 'staff', 180, 420], ['w2', 'supervisor', 120, 300]], [1, 3, 0, 2, 1], 60],
[[0, 0, 2], [1, 0, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w1', 'supervisor', 60, 180], ['w1', 'staff', 180, 210], ['w1', 'staff', 90, 270]], [3, 2, 2, 1], 60],
[[0, 0, 6], [1, 2, 4], [2, 2, 4]]),
('partial repair guard 3',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 30, 150], ['w1', 'trainee', 30, 120], ['w1', 'trainee', 90, 120],
['w1', 'supervisor', 90, 180], ['w4', 'trainee', 120, 150], ['w4', 'trainee', 180, 360]],
[3, 3, 3, 1, 3, 1], 60],
[[0, 0, 6], [1, 3, 6], [2, 2, 6], [3, 1, 2], [4, 1, 6], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 180, 300], ['w1', 'staff', 90, 210], ['w4', 'supervisor', 120, 360],
['w1', 'staff', 90, 270], ['w4', 'supervisor', 180, 210], ['w2', 'trainee', 0, 30],
['w4', 'staff', 90, 270]],
[1, 2, 3, 0, 2], 60],
[[0, 0, 2], [1, 0, 4], [2, 4, 6]]),
('normal control 7',
[[['w2', 'staff', 90, 180], ['w4', 'supervisor', 0, 180], ['w3', 'supervisor', 0, 30]], [0, 1, 3, 1, 3, 1],
60],
[[2, 4, 6], [3, 0, 2], [4, 0, 6], [5, 0, 2]]),
('normal control 8',
[[['w3', 'staff', 180, 270], ['w4', 'staff', 30, 60], ['w4', 'staff', 120, 180]], [3, 1, 1], 60],
[[0, 0, 6], [1, 0, 2]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: half head comparison 1 | [] | [[0, 2, 4]] | Failed |
| regression variant: half head comparison 2 | [] | [[0, 2, 4]] | Failed |
| partial repair guard 3 | [[2, 2, 6]] | [[1, 1, 2], [2, 2, 6]] | Failed |
| normal control 4 | [[3, 2, 6]] | [[3, 2, 6]] | Passed |
| normal control 5 | [[3, 0, 6]] | [[1, 4, 6], [2, 1, 2], [3, 0, 6]] | Failed |
| normal control 6 | [[4, 0, 6]] | [[0, 1, 2], [4, 0, 6]] | Failed |
| normal control 7 | [[0, 2, 6]] | [[0, 2, 6], [1, 3, 6], [2, 3, 4]] | Failed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [5, 0, 6]] | [[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]] | Failed |
SHA-256 / f84f8845540ab7fad32af123432a4da90f39e812ed2fa66dd47bb650a0eb5d30
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 >= b:
seen[w] = max(seen.get(w, 0), 1 if role == 'trainee' else 2)
have = sum(seen.values())
if (have + 1) // 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: half head comparison 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: half head comparison 2',
[[['w4', 'staff', 120, 360], ['w2', 'supervisor', 60, 150], ['w4', 'staff', 0, 180],
['w3', 'staff', 180, 270]],
[2, 2, 0, 2, 1], 60],
[[0, 2, 4]]),
('partial repair guard 3', [[['w2', 'trainee', 60, 120], ['w1', 'staff', 120, 300]], [0, 1, 3, 1, 1], 60],
[[1, 1, 2], [2, 2, 6]]),
('normal control 4',
[[['w3', 'supervisor', 60, 150], ['w4', 'staff', 60, 300], ['w1', 'staff', 90, 210]], [0, 0, 0, 3, 0], 60],
[[3, 2, 6]]),
('normal control 5',
[[['w2', 'supervisor', 0, 120], ['w1', 'supervisor', 60, 90], ['w1', 'supervisor', 0, 120],
['w2', 'trainee', 90, 210]],
[0, 3, 1, 3], 60],
[[1, 4, 6], [2, 1, 2], [3, 0, 6]]),
('normal control 6',
[[['w1', 'trainee', 90, 180], ['w3', 'staff', 90, 270], ['w3', 'staff', 30, 60], ['w3', 'trainee', 0, 240],
['w3', 'supervisor', 60, 90], ['w3', 'trainee', 30, 150]],
[1, 0, 0, 0, 3], 60],
[[0, 1, 2], [4, 0, 6]]),
('normal control 7',
[[['w3', 'trainee', 90, 210], ['w4', 'staff', 90, 150], ['w3', 'trainee', 60, 300],
['w3', 'staff', 90, 120], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150],
['w4', 'supervisor', 30, 210]],
[3, 3, 2, 0], 60],
[[0, 2, 6], [1, 3, 6], [2, 3, 4]]),
('normal control 8',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]])],
[('regression: half head comparison 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: half head comparison 2',
[[['w1', 'trainee', 120, 360], ['w3', 'staff', 60, 180], ['w3', 'supervisor', 30, 60]], [0, 3, 2], 60],
[[1, 2, 6], [2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5', [[['w1', 'staff', 60, 150], ['w1', 'staff', 0, 120]], [0, 3, 3, 3, 1, 2], 60],
[[1, 2, 6], [2, 0, 6], [3, 0, 6], [4, 0, 2], [5, 0, 4]]),
('normal control 6',
[[['w1', 'supervisor', 90, 180], ['w1', 'staff', 30, 120], ['w2', 'staff', 0, 180]], [0, 1, 0, 1, 0, 1],
60],
[[3, 0, 2], [5, 0, 2]]),
('normal control 7',
[[['w2', 'staff', 0, 90], ['w4', 'staff', 180, 270], ['w3', 'trainee', 180, 210],
['w3', 'staff', 180, 360], ['w2', 'staff', 0, 90], ['w2', 'staff', 90, 180],
['w1', 'trainee', 120, 300]],
[1, 0, 1], 60],
[]),
('normal control 8',
[[['w2', 'supervisor', 180, 240], ['w2', 'staff', 0, 30], ['w2', 'staff', 120, 180],
['w2', 'trainee', 180, 420], ['w2', 'supervisor', 180, 240], ['w4', 'staff', 30, 150]],
[2, 0, 1, 3], 60],
[[0, 0, 4], [3, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w3', 'staff', 0, 240], ['w1', 'supervisor', 180, 270], ['w1', 'trainee', 120, 240]], [1, 1, 2, 0], 60],
[[2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5', [[['w1', 'trainee', 30, 90], ['w1', 'supervisor', 30, 210]], [0, 0, 3, 2, 1], 60],
[[2, 2, 6], [3, 0, 4], [4, 0, 2]]),
('normal control 6',
[[['w2', 'staff', 60, 90], ['w2', 'supervisor', 180, 420], ['w2', 'staff', 0, 30],
['w4', 'staff', 120, 300], ['w3', 'trainee', 90, 150], ['w3', 'staff', 180, 300]],
[3, 2, 1, 2, 0], 60],
[[0, 0, 6], [1, 0, 4]]),
('normal control 7',
[[['w3', 'trainee', 0, 240], ['w1', 'supervisor', 0, 90], ['w2', 'supervisor', 30, 120],
['w3', 'supervisor', 0, 120], ['w4', 'staff', 0, 120]],
[1, 1, 3], 60],
[[2, 1, 6]]),
('normal control 8',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w1', 'staff', 0, 180], ['w3', 'staff', 120, 180], ['w2', 'staff', 0, 90]], [0, 0, 0], 60], []),
('normal control 8', [[['w4', 'staff', 180, 420], ['w2', 'supervisor', 120, 300]], [1, 3, 0, 2, 1], 60],
[[0, 0, 2], [1, 0, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w1', 'supervisor', 60, 180], ['w1', 'staff', 180, 210], ['w1', 'staff', 90, 270]], [3, 2, 2, 1], 60],
[[0, 0, 6], [1, 2, 4], [2, 2, 4]]),
('partial repair guard 3',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 30, 150], ['w1', 'trainee', 30, 120], ['w1', 'trainee', 90, 120],
['w1', 'supervisor', 90, 180], ['w4', 'trainee', 120, 150], ['w4', 'trainee', 180, 360]],
[3, 3, 3, 1, 3, 1], 60],
[[0, 0, 6], [1, 3, 6], [2, 2, 6], [3, 1, 2], [4, 1, 6], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 180, 300], ['w1', 'staff', 90, 210], ['w4', 'supervisor', 120, 360],
['w1', 'staff', 90, 270], ['w4', 'supervisor', 180, 210], ['w2', 'trainee', 0, 30],
['w4', 'staff', 90, 270]],
[1, 2, 3, 0, 2], 60],
[[0, 0, 2], [1, 0, 4], [2, 4, 6]]),
('normal control 7',
[[['w2', 'staff', 90, 180], ['w4', 'supervisor', 0, 180], ['w3', 'supervisor', 0, 30]], [0, 1, 3, 1, 3, 1],
60],
[[2, 4, 6], [3, 0, 2], [4, 0, 6], [5, 0, 2]]),
('normal control 8',
[[['w3', 'staff', 180, 270], ['w4', 'staff', 30, 60], ['w4', 'staff', 120, 180]], [3, 1, 1], 60],
[[0, 0, 6], [1, 0, 2]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: half head comparison 1 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| regression variant: half head comparison 2 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| partial repair guard 3 | [[2, 2, 6]] | [[1, 1, 2], [2, 2, 6]] | Failed |
| normal control 4 | [[3, 2, 6]] | [[3, 2, 6]] | Passed |
| normal control 5 | [[1, 4, 6], [3, 0, 6]] | [[1, 4, 6], [2, 1, 2], [3, 0, 6]] | Failed |
| normal control 6 | [[4, 0, 6]] | [[0, 1, 2], [4, 0, 6]] | Failed |
| normal control 7 | [[0, 2, 6], [1, 3, 6]] | [[0, 2, 6], [1, 3, 6], [2, 3, 4]] | Failed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [5, 0, 6]] | [[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]] | Failed |
SHA-256 / c4f76ad0a5f78e57bac997314b928577d17c953e5123f910df188f590711249c
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: half head comparison 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: half head comparison 2',
[[['w4', 'staff', 120, 360], ['w2', 'supervisor', 60, 150], ['w4', 'staff', 0, 180],
['w3', 'staff', 180, 270]],
[2, 2, 0, 2, 1], 60],
[[0, 2, 4]]),
('partial repair guard 3', [[['w2', 'trainee', 60, 120], ['w1', 'staff', 120, 300]], [0, 1, 3, 1, 1], 60],
[[1, 1, 2], [2, 2, 6]]),
('normal control 4',
[[['w3', 'supervisor', 60, 150], ['w4', 'staff', 60, 300], ['w1', 'staff', 90, 210]], [0, 0, 0, 3, 0], 60],
[[3, 2, 6]]),
('normal control 5',
[[['w2', 'supervisor', 0, 120], ['w1', 'supervisor', 60, 90], ['w1', 'supervisor', 0, 120],
['w2', 'trainee', 90, 210]],
[0, 3, 1, 3], 60],
[[1, 4, 6], [2, 1, 2], [3, 0, 6]]),
('normal control 6',
[[['w1', 'trainee', 90, 180], ['w3', 'staff', 90, 270], ['w3', 'staff', 30, 60], ['w3', 'trainee', 0, 240],
['w3', 'supervisor', 60, 90], ['w3', 'trainee', 30, 150]],
[1, 0, 0, 0, 3], 60],
[[0, 1, 2], [4, 0, 6]]),
('normal control 7',
[[['w3', 'trainee', 90, 210], ['w4', 'staff', 90, 150], ['w3', 'trainee', 60, 300],
['w3', 'staff', 90, 120], ['w4', 'staff', 0, 240], ['w2', 'staff', 90, 150],
['w4', 'supervisor', 30, 210]],
[3, 3, 2, 0], 60],
[[0, 2, 6], [1, 3, 6], [2, 3, 4]]),
('normal control 8',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]])],
[('regression: half head comparison 1', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60],
[[0, 3, 4]]),
('regression variant: half head comparison 2',
[[['w1', 'trainee', 120, 360], ['w3', 'staff', 60, 180], ['w3', 'supervisor', 30, 60]], [0, 3, 2], 60],
[[1, 2, 6], [2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'staff', 0, 30], ['w2', 'staff', 90, 120], ['w2', 'trainee', 180, 300],
['w1', 'supervisor', 180, 240], ['w3', 'staff', 120, 150]],
[1, 2, 0, 2, 1, 3], 60],
[[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5', [[['w1', 'staff', 60, 150], ['w1', 'staff', 0, 120]], [0, 3, 3, 3, 1, 2], 60],
[[1, 2, 6], [2, 0, 6], [3, 0, 6], [4, 0, 2], [5, 0, 4]]),
('normal control 6',
[[['w1', 'supervisor', 90, 180], ['w1', 'staff', 30, 120], ['w2', 'staff', 0, 180]], [0, 1, 0, 1, 0, 1],
60],
[[3, 0, 2], [5, 0, 2]]),
('normal control 7',
[[['w2', 'staff', 0, 90], ['w4', 'staff', 180, 270], ['w3', 'trainee', 180, 210],
['w3', 'staff', 180, 360], ['w2', 'staff', 0, 90], ['w2', 'staff', 90, 180],
['w1', 'trainee', 120, 300]],
[1, 0, 1], 60],
[]),
('normal control 8',
[[['w2', 'supervisor', 180, 240], ['w2', 'staff', 0, 30], ['w2', 'staff', 120, 180],
['w2', 'trainee', 180, 420], ['w2', 'supervisor', 180, 240], ['w4', 'staff', 30, 150]],
[2, 0, 1, 3], 60],
[[0, 0, 4], [3, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w3', 'staff', 0, 240], ['w1', 'supervisor', 180, 270], ['w1', 'trainee', 120, 240]], [1, 1, 2, 0], 60],
[[2, 3, 4]]),
('partial repair guard 3',
[[['w2', 'trainee', 0, 60], ['w2', 'staff', 30, 120], ['w4', 'supervisor', 0, 90],
['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 300], ['w2', 'staff', 180, 360],
['w4', 'supervisor', 0, 60]],
[3, 3, 2, 0, 3, 0], 60],
[[0, 5, 6], [1, 2, 6], [2, 2, 4], [4, 4, 6]]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5', [[['w1', 'trainee', 30, 90], ['w1', 'supervisor', 30, 210]], [0, 0, 3, 2, 1], 60],
[[2, 2, 6], [3, 0, 4], [4, 0, 2]]),
('normal control 6',
[[['w2', 'staff', 60, 90], ['w2', 'supervisor', 180, 420], ['w2', 'staff', 0, 30],
['w4', 'staff', 120, 300], ['w3', 'trainee', 90, 150], ['w3', 'staff', 180, 300]],
[3, 2, 1, 2, 0], 60],
[[0, 0, 6], [1, 0, 4]]),
('normal control 7',
[[['w3', 'trainee', 0, 240], ['w1', 'supervisor', 0, 90], ['w2', 'supervisor', 30, 120],
['w3', 'supervisor', 0, 120], ['w4', 'staff', 0, 120]],
[1, 1, 3], 60],
[[2, 1, 6]]),
('normal control 8',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w2', 'staff', 90, 270], ['w4', 'trainee', 90, 270], ['w1', 'staff', 180, 420],
['w4', 'trainee', 90, 210], ['w1', 'supervisor', 180, 360], ['w3', 'staff', 60, 180],
['w2', 'trainee', 180, 360]],
[0, 0, 2, 0, 3], 60],
[[4, 3, 6]]),
('partial repair guard 3',
[[['w2', 'staff', 30, 210], ['w1', 'trainee', 0, 240], ['w2', 'staff', 30, 120], ['w4', 'staff', 60, 300]],
[2, 3, 1], 60],
[[0, 1, 4], [1, 5, 6]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 6',
[[['w2', 'staff', 90, 210], ['w1', 'supervisor', 60, 300], ['w1', 'staff', 60, 90],
['w4', 'staff', 180, 270], ['w4', 'staff', 30, 210]],
[2, 0, 0, 0], 60],
[[0, 0, 4]]),
('normal control 7',
[[['w1', 'staff', 0, 180], ['w3', 'staff', 120, 180], ['w2', 'staff', 0, 90]], [0, 0, 0], 60], []),
('normal control 8', [[['w4', 'staff', 180, 420], ['w2', 'supervisor', 120, 300]], [1, 3, 0, 2, 1], 60],
[[0, 0, 2], [1, 0, 6]])],
[('regression: half head comparison 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: half head comparison 2',
[[['w1', 'supervisor', 60, 180], ['w1', 'staff', 180, 210], ['w1', 'staff', 90, 270]], [3, 2, 2, 1], 60],
[[0, 0, 6], [1, 2, 4], [2, 2, 4]]),
('partial repair guard 3',
[[['w4', 'staff', 90, 330], ['w4', 'supervisor', 120, 210], ['w4', 'supervisor', 60, 180],
['w2', 'supervisor', 120, 210], ['w3', 'staff', 30, 210], ['w4', 'supervisor', 120, 300],
['w1', 'trainee', 120, 240]],
[2, 1, 2, 2, 3], 60],
[[0, 0, 4], [3, 3, 4], [4, 2, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w4', 'staff', 30, 150], ['w1', 'trainee', 30, 120], ['w1', 'trainee', 90, 120],
['w1', 'supervisor', 90, 180], ['w4', 'trainee', 120, 150], ['w4', 'trainee', 180, 360]],
[3, 3, 3, 1, 3, 1], 60],
[[0, 0, 6], [1, 3, 6], [2, 2, 6], [3, 1, 2], [4, 1, 6], [5, 1, 2]]),
('normal control 6',
[[['w1', 'staff', 180, 300], ['w1', 'staff', 90, 210], ['w4', 'supervisor', 120, 360],
['w1', 'staff', 90, 270], ['w4', 'supervisor', 180, 210], ['w2', 'trainee', 0, 30],
['w4', 'staff', 90, 270]],
[1, 2, 3, 0, 2], 60],
[[0, 0, 2], [1, 0, 4], [2, 4, 6]]),
('normal control 7',
[[['w2', 'staff', 90, 180], ['w4', 'supervisor', 0, 180], ['w3', 'supervisor', 0, 30]], [0, 1, 3, 1, 3, 1],
60],
[[2, 4, 6], [3, 0, 2], [4, 0, 6], [5, 0, 2]]),
('normal control 8',
[[['w3', 'staff', 180, 270], ['w4', 'staff', 30, 60], ['w4', 'staff', 120, 180]], [3, 1, 1], 60],
[[0, 0, 6], [1, 0, 2]])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: half head comparison 1 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| regression variant: half head comparison 2 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| partial repair guard 3 | [[1, 1, 2], [2, 2, 6]] | [[1, 1, 2], [2, 2, 6]] | Passed |
| normal control 4 | [[3, 2, 6]] | [[3, 2, 6]] | Passed |
| normal control 5 | [[1, 4, 6], [2, 1, 2], [3, 0, 6]] | [[1, 4, 6], [2, 1, 2], [3, 0, 6]] | Passed |
| normal control 6 | [[0, 1, 2], [4, 0, 6]] | [[0, 1, 2], [4, 0, 6]] | Passed |
| normal control 7 | [[0, 2, 6], [1, 3, 6], [2, 3, 4]] | [[0, 2, 6], [1, 3, 6], [2, 3, 4]] | Passed |
| normal control 8 | [[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]] | [[0, 0, 2], [1, 0, 4], [3, 3, 4], [4, 1, 2], [5, 0, 6]] | Passed |
SHA-256 / 6de89325eb4ccb9b648c3583715c82a084e832b633d04bbb6180dbfc76a996a2
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.268118+00:00.
Case digest / ecfdd7438b1061fb8b7799532342315faa792a79138aa66abf3fef5dbed02b98