FA-94096 / Shift rostering labor rules / Open access
Duplicate shift records double count one worker · case 01
A worker with overlapping duplicate entries covers a slot twice.
ROOT CAUSE
Weights are summed per worker instead of taking the best role once.
VERIFIED REPAIR
Count each worker once per slot at the maximum role weight.
Unsuccessful approach: Keeping the last record per worker downgrades a staff member recorded later as trainee.
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] = 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: worker dedupe 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('normal control 4',
[[['w1', 'trainee', 0, 90], ['w1', 'staff', 180, 360], ['w4', 'staff', 180, 240],
['w2', 'supervisor', 90, 210], ['w2', 'trainee', 180, 420]],
[1, 2, 2, 2, 2, 1], 60],
[[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]]),
('normal control 5',
[[['w1', 'trainee', 30, 150], ['w2', 'trainee', 120, 180], ['w3', 'trainee', 30, 90],
['w3', 'supervisor', 90, 330], ['w2', 'staff', 180, 240]],
[1, 0, 2], 60],
[[0, 0, 2], [2, 3, 4]]),
('normal control 6',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 7',
[[['w2', 'supervisor', 60, 180], ['w1', 'supervisor', 90, 150], ['w4', 'trainee', 0, 240],
['w3', 'staff', 30, 90], ['w4', 'staff', 90, 120]],
[3, 0, 2], 60],
[[0, 1, 6], [2, 3, 4]]),
('normal control 8', [[['w1', 'staff', 90, 120], ['w1', 'supervisor', 0, 90]], [3, 3, 3, 2, 0], 60],
[[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]])],
[('regression: worker dedupe 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: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['w4', 'supervisor', 90, 150], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 210],
['w3', 'trainee', 60, 240]],
[0, 1, 1, 2, 3], 60],
[[1, 1, 2], [3, 1, 4], [4, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w4', 'staff', 120, 150], ['w1', 'staff', 30, 60], ['w3', 'staff', 0, 180], ['w2', 'trainee', 90, 150]],
[2, 3, 1, 0, 0, 2], 60],
[[0, 2, 4], [1, 2, 6], [5, 0, 4]]),
('normal control 7',
[[['w3', 'staff', 60, 120], ['w2', 'staff', 60, 150], ['w1', 'trainee', 0, 240], ['w3', 'staff', 30, 60],
['w3', 'supervisor', 180, 240], ['w3', 'trainee', 90, 120]],
[1, 0, 0], 60],
[[0, 1, 2]]),
('normal control 8',
[[['w1', 'staff', 0, 120], ['w1', 'supervisor', 30, 270], ['w3', 'trainee', 120, 180],
['w1', 'staff', 60, 300]],
[0, 0, 0, 3], 60],
[[3, 2, 6]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 90, 210], ['w4', 'staff', 120, 180], ['w1', 'supervisor', 0, 60],
['w4', 'trainee', 120, 360]],
[2, 3, 2, 0, 0, 1], 60],
[[0, 2, 4], [1, 0, 6], [2, 2, 4], [5, 1, 2]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('partial repair guard 3',
[[['w3', 'trainee', 180, 240], ['w4', 'supervisor', 120, 300], ['w4', 'staff', 0, 60],
['w2', 'supervisor', 60, 120], ['w3', 'staff', 180, 270], ['w3', 'staff', 60, 240],
['w4', 'trainee', 30, 270]],
[1, 2, 2, 1, 0], 60],
[]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'staff', 60, 180], ['w2', 'supervisor', 120, 360], ['w3', 'staff', 60, 180],
['w2', 'staff', 180, 360], ['w3', 'staff', 0, 30], ['w3', 'supervisor', 90, 150],
['w3', 'supervisor', 30, 90]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 30, 150], ['w1', 'staff', 120, 150], ['w1', 'staff', 120, 150],
['w1', 'trainee', 90, 210], ['w1', 'staff', 60, 300], ['w1', 'staff', 30, 150],
['w1', 'staff', 120, 360]],
[2, 3, 1], 60],
[[0, 0, 4], [1, 4, 6]]),
('normal control 7',
[[['w4', 'trainee', 120, 300], ['w3', 'staff', 90, 330], ['w2', 'trainee', 0, 180],
['w3', 'staff', 90, 330], ['w3', 'trainee', 120, 210], ['w1', 'supervisor', 90, 150]],
[1, 1, 3, 1], 60],
[[0, 1, 2], [1, 1, 2], [2, 4, 6]]),
('normal control 8',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[])],
[('regression: worker dedupe 1',
[[['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]]),
('regression variant: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['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]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'trainee', 180, 270], ['w4', 'staff', 120, 150], ['w4', 'staff', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'staff', 180, 240], ['w4', 'staff', 0, 240],
['w2', 'supervisor', 0, 60]],
[2, 2, 1, 1, 2, 1], 60],
[[1, 3, 4], [4, 0, 4], [5, 0, 2]]),
('normal control 6', [[['w4', 'staff', 120, 150], ['w3', 'supervisor', 180, 270]], [1, 3, 0], 60],
[[0, 0, 2], [1, 0, 6]]),
('normal control 7',
[[['w2', 'trainee', 120, 240], ['w1', 'staff', 90, 150], ['w1', 'supervisor', 180, 300]], [2, 2, 2, 1],
60],
[[0, 0, 4], [1, 0, 4], [2, 1, 4]]),
('normal control 8', [[['w2', 'trainee', 30, 120], ['w4', 'trainee', 30, 210]], [2, 2, 0, 1, 1, 0], 60],
[[0, 0, 4], [1, 2, 4], [3, 0, 2], [4, 0, 2]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 30, 270], ['w3', 'staff', 30, 120], ['w4', 'staff', 30, 210], ['w4', 'staff', 0, 120],
['w3', 'staff', 30, 150]],
[1, 1, 2, 2], 60],
[[2, 2, 4], [3, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w4', 'trainee', 0, 90], ['w3', 'staff', 120, 360], ['w2', 'supervisor', 180, 300],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 0, 90]],
[2, 3, 0], 60],
[[0, 2, 4], [1, 0, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w2', 'supervisor', 120, 180], ['w4', 'trainee', 30, 150], ['w3', 'staff', 180, 420],
['w2', 'staff', 30, 90], ['w1', 'supervisor', 30, 210], ['w2', 'staff', 0, 180],
['w1', 'trainee', 90, 210]],
[2, 3, 0, 0, 0, 1], 60],
[[0, 2, 4], [1, 5, 6]]),
('normal control 6',
[[['w3', 'supervisor', 180, 240], ['w3', 'staff', 180, 270], ['w1', 'trainee', 60, 300],
['w4', 'trainee', 60, 120], ['w4', 'staff', 0, 180]],
[3, 2, 3, 0, 3, 2], 60],
[[0, 2, 6], [1, 3, 4], [2, 3, 6], [4, 1, 6], [5, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 120, 210], ['w3', 'trainee', 120, 180], ['w4', 'staff', 60, 150],
['w2', 'supervisor', 0, 180], ['w2', 'staff', 90, 150], ['w3', 'trainee', 180, 270]],
[2, 1, 1, 3, 2], 60],
[[0, 2, 4], [3, 1, 6], [4, 0, 4]]),
('normal control 8',
[[['w3', 'supervisor', 30, 270], ['w1', 'staff', 60, 240], ['w4', 'trainee', 0, 180],
['w2', 'staff', 0, 180], ['w3', 'staff', 0, 90], ['w2', 'trainee', 30, 90],
['w4', 'supervisor', 180, 360]],
[1, 3, 2], 60],
[])]]
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: worker dedupe 1 | [[0, 3, 4]] | [[0, 2, 4]] | Failed |
| regression variant: worker dedupe 2 | [[0, 0, 2], [3, 3, 6]] | [[0, 0, 2], [3, 2, 6]] | Failed |
| partial repair guard 3 | [[0, 2, 4], [1, 1, 2], [4, 0, 2], [5, 0, 6]] | [[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]] | Failed |
| normal control 4 | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | Passed |
| normal control 5 | [[0, 0, 2], [2, 3, 4]] | [[0, 0, 2], [2, 3, 4]] | Passed |
| normal control 6 | [] | [] | Passed |
| normal control 7 | [[0, 1, 6], [2, 3, 4]] | [[0, 1, 6], [2, 3, 4]] | Passed |
| normal control 8 | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | Passed |
SHA-256 / bf338a481fcf9dae887dd005f7f48d9d8264df9683b0b1b3489e0cb18359ac4c
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] = (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: worker dedupe 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('normal control 4',
[[['w1', 'trainee', 0, 90], ['w1', 'staff', 180, 360], ['w4', 'staff', 180, 240],
['w2', 'supervisor', 90, 210], ['w2', 'trainee', 180, 420]],
[1, 2, 2, 2, 2, 1], 60],
[[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]]),
('normal control 5',
[[['w1', 'trainee', 30, 150], ['w2', 'trainee', 120, 180], ['w3', 'trainee', 30, 90],
['w3', 'supervisor', 90, 330], ['w2', 'staff', 180, 240]],
[1, 0, 2], 60],
[[0, 0, 2], [2, 3, 4]]),
('normal control 6',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 7',
[[['w2', 'supervisor', 60, 180], ['w1', 'supervisor', 90, 150], ['w4', 'trainee', 0, 240],
['w3', 'staff', 30, 90], ['w4', 'staff', 90, 120]],
[3, 0, 2], 60],
[[0, 1, 6], [2, 3, 4]]),
('normal control 8', [[['w1', 'staff', 90, 120], ['w1', 'supervisor', 0, 90]], [3, 3, 3, 2, 0], 60],
[[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]])],
[('regression: worker dedupe 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: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['w4', 'supervisor', 90, 150], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 210],
['w3', 'trainee', 60, 240]],
[0, 1, 1, 2, 3], 60],
[[1, 1, 2], [3, 1, 4], [4, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w4', 'staff', 120, 150], ['w1', 'staff', 30, 60], ['w3', 'staff', 0, 180], ['w2', 'trainee', 90, 150]],
[2, 3, 1, 0, 0, 2], 60],
[[0, 2, 4], [1, 2, 6], [5, 0, 4]]),
('normal control 7',
[[['w3', 'staff', 60, 120], ['w2', 'staff', 60, 150], ['w1', 'trainee', 0, 240], ['w3', 'staff', 30, 60],
['w3', 'supervisor', 180, 240], ['w3', 'trainee', 90, 120]],
[1, 0, 0], 60],
[[0, 1, 2]]),
('normal control 8',
[[['w1', 'staff', 0, 120], ['w1', 'supervisor', 30, 270], ['w3', 'trainee', 120, 180],
['w1', 'staff', 60, 300]],
[0, 0, 0, 3], 60],
[[3, 2, 6]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 90, 210], ['w4', 'staff', 120, 180], ['w1', 'supervisor', 0, 60],
['w4', 'trainee', 120, 360]],
[2, 3, 2, 0, 0, 1], 60],
[[0, 2, 4], [1, 0, 6], [2, 2, 4], [5, 1, 2]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('partial repair guard 3',
[[['w3', 'trainee', 180, 240], ['w4', 'supervisor', 120, 300], ['w4', 'staff', 0, 60],
['w2', 'supervisor', 60, 120], ['w3', 'staff', 180, 270], ['w3', 'staff', 60, 240],
['w4', 'trainee', 30, 270]],
[1, 2, 2, 1, 0], 60],
[]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'staff', 60, 180], ['w2', 'supervisor', 120, 360], ['w3', 'staff', 60, 180],
['w2', 'staff', 180, 360], ['w3', 'staff', 0, 30], ['w3', 'supervisor', 90, 150],
['w3', 'supervisor', 30, 90]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 30, 150], ['w1', 'staff', 120, 150], ['w1', 'staff', 120, 150],
['w1', 'trainee', 90, 210], ['w1', 'staff', 60, 300], ['w1', 'staff', 30, 150],
['w1', 'staff', 120, 360]],
[2, 3, 1], 60],
[[0, 0, 4], [1, 4, 6]]),
('normal control 7',
[[['w4', 'trainee', 120, 300], ['w3', 'staff', 90, 330], ['w2', 'trainee', 0, 180],
['w3', 'staff', 90, 330], ['w3', 'trainee', 120, 210], ['w1', 'supervisor', 90, 150]],
[1, 1, 3, 1], 60],
[[0, 1, 2], [1, 1, 2], [2, 4, 6]]),
('normal control 8',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[])],
[('regression: worker dedupe 1',
[[['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]]),
('regression variant: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['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]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'trainee', 180, 270], ['w4', 'staff', 120, 150], ['w4', 'staff', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'staff', 180, 240], ['w4', 'staff', 0, 240],
['w2', 'supervisor', 0, 60]],
[2, 2, 1, 1, 2, 1], 60],
[[1, 3, 4], [4, 0, 4], [5, 0, 2]]),
('normal control 6', [[['w4', 'staff', 120, 150], ['w3', 'supervisor', 180, 270]], [1, 3, 0], 60],
[[0, 0, 2], [1, 0, 6]]),
('normal control 7',
[[['w2', 'trainee', 120, 240], ['w1', 'staff', 90, 150], ['w1', 'supervisor', 180, 300]], [2, 2, 2, 1],
60],
[[0, 0, 4], [1, 0, 4], [2, 1, 4]]),
('normal control 8', [[['w2', 'trainee', 30, 120], ['w4', 'trainee', 30, 210]], [2, 2, 0, 1, 1, 0], 60],
[[0, 0, 4], [1, 2, 4], [3, 0, 2], [4, 0, 2]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 30, 270], ['w3', 'staff', 30, 120], ['w4', 'staff', 30, 210], ['w4', 'staff', 0, 120],
['w3', 'staff', 30, 150]],
[1, 1, 2, 2], 60],
[[2, 2, 4], [3, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w4', 'trainee', 0, 90], ['w3', 'staff', 120, 360], ['w2', 'supervisor', 180, 300],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 0, 90]],
[2, 3, 0], 60],
[[0, 2, 4], [1, 0, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w2', 'supervisor', 120, 180], ['w4', 'trainee', 30, 150], ['w3', 'staff', 180, 420],
['w2', 'staff', 30, 90], ['w1', 'supervisor', 30, 210], ['w2', 'staff', 0, 180],
['w1', 'trainee', 90, 210]],
[2, 3, 0, 0, 0, 1], 60],
[[0, 2, 4], [1, 5, 6]]),
('normal control 6',
[[['w3', 'supervisor', 180, 240], ['w3', 'staff', 180, 270], ['w1', 'trainee', 60, 300],
['w4', 'trainee', 60, 120], ['w4', 'staff', 0, 180]],
[3, 2, 3, 0, 3, 2], 60],
[[0, 2, 6], [1, 3, 4], [2, 3, 6], [4, 1, 6], [5, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 120, 210], ['w3', 'trainee', 120, 180], ['w4', 'staff', 60, 150],
['w2', 'supervisor', 0, 180], ['w2', 'staff', 90, 150], ['w3', 'trainee', 180, 270]],
[2, 1, 1, 3, 2], 60],
[[0, 2, 4], [3, 1, 6], [4, 0, 4]]),
('normal control 8',
[[['w3', 'supervisor', 30, 270], ['w1', 'staff', 60, 240], ['w4', 'trainee', 0, 180],
['w2', 'staff', 0, 180], ['w3', 'staff', 0, 90], ['w2', 'trainee', 30, 90],
['w4', 'supervisor', 180, 360]],
[1, 3, 2], 60],
[])]]
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: worker dedupe 1 | [[0, 1, 4]] | [[0, 2, 4]] | Failed |
| regression variant: worker dedupe 2 | [[0, 0, 2], [2, 3, 4], [3, 1, 6]] | [[0, 0, 2], [3, 2, 6]] | Failed |
| partial repair guard 3 | [[0, 2, 4], [1, 1, 2], [2, 4, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]] | [[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]] | Failed |
| normal control 4 | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | Passed |
| normal control 5 | [[0, 0, 2], [2, 3, 4]] | [[0, 0, 2], [2, 3, 4]] | Passed |
| normal control 6 | [] | [] | Passed |
| normal control 7 | [[0, 1, 6], [2, 3, 4]] | [[0, 1, 6], [2, 3, 4]] | Passed |
| normal control 8 | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | Passed |
SHA-256 / 058268afdfa545c5dc96f3f8767f9332c9c5bb194431fa9262f7e1b20c624133
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: worker dedupe 1', [[['w1', 'staff', 0, 120], ['w1', 'trainee', 0, 60]], [2, 1], 60],
[[0, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 270], ['w4', 'supervisor', 90, 210], ['w3', 'trainee', 60, 300],
['w4', 'trainee', 90, 150]],
[1, 0, 2, 3, 0], 60],
[[0, 0, 2], [3, 2, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('normal control 4',
[[['w1', 'trainee', 0, 90], ['w1', 'staff', 180, 360], ['w4', 'staff', 180, 240],
['w2', 'supervisor', 90, 210], ['w2', 'trainee', 180, 420]],
[1, 2, 2, 2, 2, 1], 60],
[[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]]),
('normal control 5',
[[['w1', 'trainee', 30, 150], ['w2', 'trainee', 120, 180], ['w3', 'trainee', 30, 90],
['w3', 'supervisor', 90, 330], ['w2', 'staff', 180, 240]],
[1, 0, 2], 60],
[[0, 0, 2], [2, 3, 4]]),
('normal control 6',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[]),
('normal control 7',
[[['w2', 'supervisor', 60, 180], ['w1', 'supervisor', 90, 150], ['w4', 'trainee', 0, 240],
['w3', 'staff', 30, 90], ['w4', 'staff', 90, 120]],
[3, 0, 2], 60],
[[0, 1, 6], [2, 3, 4]]),
('normal control 8', [[['w1', 'staff', 90, 120], ['w1', 'supervisor', 0, 90]], [3, 3, 3, 2, 0], 60],
[[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]])],
[('regression: worker dedupe 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: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['w4', 'supervisor', 90, 150], ['w1', 'supervisor', 0, 90], ['w3', 'staff', 120, 210],
['w3', 'trainee', 60, 240]],
[0, 1, 1, 2, 3], 60],
[[1, 1, 2], [3, 1, 4], [4, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 30, 120]], [1, 1], 60], [[0, 0, 2]]),
('normal control 5',
[[['w1', 'supervisor', 0, 120], ['w3', 'trainee', 120, 240], ['w1', 'staff', 60, 150],
['w3', 'trainee', 0, 120], ['w2', 'supervisor', 60, 240], ['w1', 'staff', 60, 300],
['w1', 'staff', 30, 60]],
[1, 3, 2, 1, 3], 60],
[[1, 5, 6], [4, 2, 6]]),
('normal control 6',
[[['w4', 'staff', 120, 150], ['w1', 'staff', 30, 60], ['w3', 'staff', 0, 180], ['w2', 'trainee', 90, 150]],
[2, 3, 1, 0, 0, 2], 60],
[[0, 2, 4], [1, 2, 6], [5, 0, 4]]),
('normal control 7',
[[['w3', 'staff', 60, 120], ['w2', 'staff', 60, 150], ['w1', 'trainee', 0, 240], ['w3', 'staff', 30, 60],
['w3', 'supervisor', 180, 240], ['w3', 'trainee', 90, 120]],
[1, 0, 0], 60],
[[0, 1, 2]]),
('normal control 8',
[[['w1', 'staff', 0, 120], ['w1', 'supervisor', 30, 270], ['w3', 'trainee', 120, 180],
['w1', 'staff', 60, 300]],
[0, 0, 0, 3], 60],
[[3, 2, 6]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 90, 210], ['w4', 'staff', 120, 180], ['w1', 'supervisor', 0, 60],
['w4', 'trainee', 120, 360]],
[2, 3, 2, 0, 0, 1], 60],
[[0, 2, 4], [1, 0, 6], [2, 2, 4], [5, 1, 2]]),
('regression variant: worker dedupe 2',
[[['w3', 'staff', 30, 150], ['w3', 'trainee', 60, 150], ['w4', 'supervisor', 0, 30],
['w1', 'staff', 90, 270], ['w1', 'trainee', 90, 330], ['w4', 'staff', 30, 90],
['w1', 'supervisor', 180, 210]],
[1, 2, 0, 2], 60],
[[0, 0, 2], [1, 2, 4], [3, 2, 4]]),
('partial repair guard 3',
[[['w3', 'trainee', 180, 240], ['w4', 'supervisor', 120, 300], ['w4', 'staff', 0, 60],
['w2', 'supervisor', 60, 120], ['w3', 'staff', 180, 270], ['w3', 'staff', 60, 240],
['w4', 'trainee', 30, 270]],
[1, 2, 2, 1, 0], 60],
[]),
('boundary control 4', [[['w1', 'supervisor', 0, 60], ['w2', 'trainee', 0, 60]], [2], 60], [[0, 3, 4]]),
('normal control 5',
[[['w3', 'staff', 60, 180], ['w2', 'supervisor', 120, 360], ['w3', 'staff', 60, 180],
['w2', 'staff', 180, 360], ['w3', 'staff', 0, 30], ['w3', 'supervisor', 90, 150],
['w3', 'supervisor', 30, 90]],
[1, 3, 1, 1, 0], 60],
[[0, 0, 2], [1, 2, 6]]),
('normal control 6',
[[['w2', 'staff', 30, 150], ['w1', 'staff', 120, 150], ['w1', 'staff', 120, 150],
['w1', 'trainee', 90, 210], ['w1', 'staff', 60, 300], ['w1', 'staff', 30, 150],
['w1', 'staff', 120, 360]],
[2, 3, 1], 60],
[[0, 0, 4], [1, 4, 6]]),
('normal control 7',
[[['w4', 'trainee', 120, 300], ['w3', 'staff', 90, 330], ['w2', 'trainee', 0, 180],
['w3', 'staff', 90, 330], ['w3', 'trainee', 120, 210], ['w1', 'supervisor', 90, 150]],
[1, 1, 3, 1], 60],
[[0, 1, 2], [1, 1, 2], [2, 4, 6]]),
('normal control 8',
[[['w1', 'staff', 60, 240], ['w3', 'trainee', 0, 180], ['w3', 'trainee', 0, 60],
['w2', 'trainee', 0, 120]],
[0, 0, 0, 0], 60],
[])],
[('regression: worker dedupe 1',
[[['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]]),
('regression variant: worker dedupe 2',
[[['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]]),
('partial repair guard 3',
[[['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]]),
('boundary control 4', [[['w1', 'trainee', 0, 60], ['w2', 'trainee', 0, 60]], [1], 60], []),
('normal control 5',
[[['w3', 'trainee', 180, 270], ['w4', 'staff', 120, 150], ['w4', 'staff', 120, 180],
['w2', 'trainee', 0, 120], ['w2', 'staff', 180, 240], ['w4', 'staff', 0, 240],
['w2', 'supervisor', 0, 60]],
[2, 2, 1, 1, 2, 1], 60],
[[1, 3, 4], [4, 0, 4], [5, 0, 2]]),
('normal control 6', [[['w4', 'staff', 120, 150], ['w3', 'supervisor', 180, 270]], [1, 3, 0], 60],
[[0, 0, 2], [1, 0, 6]]),
('normal control 7',
[[['w2', 'trainee', 120, 240], ['w1', 'staff', 90, 150], ['w1', 'supervisor', 180, 300]], [2, 2, 2, 1],
60],
[[0, 0, 4], [1, 0, 4], [2, 1, 4]]),
('normal control 8', [[['w2', 'trainee', 30, 120], ['w4', 'trainee', 30, 210]], [2, 2, 0, 1, 1, 0], 60],
[[0, 0, 4], [1, 2, 4], [3, 0, 2], [4, 0, 2]])],
[('regression: worker dedupe 1',
[[['w4', 'staff', 30, 270], ['w3', 'staff', 30, 120], ['w4', 'staff', 30, 210], ['w4', 'staff', 0, 120],
['w3', 'staff', 30, 150]],
[1, 1, 2, 2], 60],
[[2, 2, 4], [3, 2, 4]]),
('regression variant: worker dedupe 2',
[[['w4', 'trainee', 0, 90], ['w3', 'staff', 120, 360], ['w2', 'supervisor', 180, 300],
['w4', 'staff', 180, 360], ['w4', 'supervisor', 0, 90]],
[2, 3, 0], 60],
[[0, 2, 4], [1, 0, 6]]),
('partial repair guard 3',
[[['w3', 'staff', 90, 270], ['w3', 'trainee', 120, 210], ['w3', 'supervisor', 180, 270],
['w1', 'trainee', 60, 120], ['w1', 'supervisor', 90, 180], ['w2', 'staff', 0, 60],
['w4', 'trainee', 90, 270]],
[2, 1, 3, 2, 1, 3], 60],
[[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]]),
('boundary control 4', [[['w1', 'staff', 0, 60]], [1, 1], 60], [[1, 0, 2]]),
('normal control 5',
[[['w2', 'supervisor', 120, 180], ['w4', 'trainee', 30, 150], ['w3', 'staff', 180, 420],
['w2', 'staff', 30, 90], ['w1', 'supervisor', 30, 210], ['w2', 'staff', 0, 180],
['w1', 'trainee', 90, 210]],
[2, 3, 0, 0, 0, 1], 60],
[[0, 2, 4], [1, 5, 6]]),
('normal control 6',
[[['w3', 'supervisor', 180, 240], ['w3', 'staff', 180, 270], ['w1', 'trainee', 60, 300],
['w4', 'trainee', 60, 120], ['w4', 'staff', 0, 180]],
[3, 2, 3, 0, 3, 2], 60],
[[0, 2, 6], [1, 3, 4], [2, 3, 6], [4, 1, 6], [5, 0, 4]]),
('normal control 7',
[[['w4', 'staff', 120, 210], ['w3', 'trainee', 120, 180], ['w4', 'staff', 60, 150],
['w2', 'supervisor', 0, 180], ['w2', 'staff', 90, 150], ['w3', 'trainee', 180, 270]],
[2, 1, 1, 3, 2], 60],
[[0, 2, 4], [3, 1, 6], [4, 0, 4]]),
('normal control 8',
[[['w3', 'supervisor', 30, 270], ['w1', 'staff', 60, 240], ['w4', 'trainee', 0, 180],
['w2', 'staff', 0, 180], ['w3', 'staff', 0, 90], ['w2', 'trainee', 30, 90],
['w4', 'supervisor', 180, 360]],
[1, 3, 2], 60],
[])]]
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: worker dedupe 1 | [[0, 2, 4]] | [[0, 2, 4]] | Passed |
| regression variant: worker dedupe 2 | [[0, 0, 2], [3, 2, 6]] | [[0, 0, 2], [3, 2, 6]] | Passed |
| partial repair guard 3 | [[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]] | [[0, 2, 4], [1, 1, 2], [2, 5, 6], [3, 3, 4], [4, 0, 2], [5, 0, 6]] | Passed |
| normal control 4 | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | [[0, 1, 2], [1, 0, 4], [2, 2, 4], [4, 3, 4]] | Passed |
| normal control 5 | [[0, 0, 2], [2, 3, 4]] | [[0, 0, 2], [2, 3, 4]] | Passed |
| normal control 6 | [] | [] | Passed |
| normal control 7 | [[0, 1, 6], [2, 3, 4]] | [[0, 1, 6], [2, 3, 4]] | Passed |
| normal control 8 | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | [[0, 2, 6], [1, 0, 6], [2, 0, 6], [3, 0, 4]] | Passed |
SHA-256 / f71c8126f5dfc0d13161aac43180c75c6182933e54c3cb76b3293937875c9d21
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.259678+00:00.
Case digest / dbb8a1ffcd4d3bdee72bd205eb76c5fdcac12de61231fe4b7a8ef4d2c4c6e9dc