FAILURE MAP
← Case archive

FA-93961 / Shift rostering labor rules / Open access

Meal ordinals assigned in log order · case 01

When the second meal is logged first it is judged against the first meal deadline.

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

ROOT CAUSE

Counted meals are not sorted by start before deadlines are assigned.

VERIFIED REPAIR

Sort counted meal starts ascending before assigning ordinals.

Unsuccessful approach: Sorting descending assigns the later meal to the first deadline.

Case contract

Shift [start, end] and breaks [start, end, kind]. Meals required: one if the shift exceeds 300 minutes, two if it exceeds 600. A meal counts if it lasts at least 30 minutes and lies inside the shift; the k-th counted meal (by start) is late if it starts after shift start + 300*k. Rest breaks required: none under 210 minutes, else (L + 120) // 240 (one per four hours or major fraction); a rest counts if kind is rest and it lasts at least 10 minutes. Return required meals, late meal ordinals, missing meals and missing rests.

Why this case matters

Break-entitlement checks gate roster publication and trigger premium pay; every boundary here is a distinct audit finding.

1 / The failure

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

N = 1
observations = []
def solve(shift, breaks):
    s, e = shift
    L = e - s
    need_meal = (L > 300) + (L > 600)
    meals = list(b[0] for b in breaks if b[2] == 'meal' and b[1] - b[0] >= 30 and b[0] >= s and b[1] <= e)
    late = [k + 1 for k, start in enumerate(meals[:need_meal]) if start > s + 300 * (k + 1)]
    need_rest = 0 if L < 210 else (L + 120) // 240
    rests = sum(1 for b in breaks if b[2] == 'rest' and b[1] - b[0] >= 10)
    return {'meals_required': need_meal, 'late': late, 'missing_meal': max(need_meal - len(meals), 0),
            'missing_rest': max(need_rest - rests, 0)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 3', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 4', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[1320, 2040], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 6', [[420, 780], [[540, 549, 'rest'], [980, 1025, 'meal'], [380, 425, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7', [[0, 480], [[560, 580, 'meal'], [300, 345, 'meal'], [270, 301, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 2', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 4',
   [[0, 360], [[120, 150, 'meal'], [340, 355, 'rest'], [60, 90, 'meal'], [600, 615, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 5', [[420, 1080], [[1020, 1051, 'meal']]],
   {'meals_required': 2, 'late': [1], 'missing_meal': 1, 'missing_rest': 3}),
  ('normal control 6',
   [[360, 1080], [[420, 430, 'meal'], [960, 970, 'rest'], [420, 430, 'meal'], [690, 699, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 2}),
  ('normal control 7', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 209], [[120, 140, 'meal'], [300, 315, 'rest'], [301, 310, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})],
 [('regression: meal order 1', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('regression variant: meal order 2', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 3',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('boundary control 4', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 5', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 480], [[-40, -30, 'rest'], [460, 475, 'rest'], [200, 215, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 7', [[1320, 1621], [[1590, 1621, 'meal'], [1920, 1935, 'meal'], [1280, 1311, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 8', [[0, 359], [[120, 149, 'meal'], [120, 135, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('partial repair guard 2', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 4',
   [[360, 1080], [[1060, 1070, 'rest'], [690, 705, 'rest'], [660, 691, 'meal'], [920, 949, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 5',
   [[0, 600], [[200, 215, 'rest'], [-40, -11, 'meal'], [120, 135, 'rest'], [60, 70, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 780], [[480, 490, 'rest'], [380, 400, 'meal'], [690, 699, 'meal'], [980, 990, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('partial repair guard 3',
   [[420, 1080], [[480, 511, 'meal'], [750, 780, 'meal'], [1020, 1051, 'meal'], [620, 629, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 4', [[1320, 1920], [[1600, 1629, 'meal'], [1450, 1460, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 5', [[1320, 1500], [[1280, 1295, 'rest'], [1650, 1679, 'meal'], [1480, 1490, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1530], [[1380, 1389, 'rest'], [1880, 1895, 'meal'], [1525, 1534, 'meal'], [1440, 1449, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7',
   [[360, 569], [[630, 659, 'meal'], [549, 578, 'meal'], [960, 989, 'meal'], [320, 335, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[1320, 1620], [[1440, 1470, 'meal'], [1620, 1640, 'meal'], [1650, 1665, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})]]
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: meal order 1{'late': [1], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}Failed
regression variant: meal order 2{'late': [1], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}Failed
boundary control 3{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 4{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}Passed
normal control 5{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed
normal control 6{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Passed
normal control 7{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}Passed
normal control 8{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Passed

SHA-256 / 4e17223c2c0d803204b2dc5d737d7d14488282a5de428678fafa0bbc2e17be45

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shift, breaks):
    s, e = shift
    L = e - s
    need_meal = (L > 300) + (L > 600)
    meals = sorted((b[0] for b in breaks if b[2] == 'meal' and b[1] - b[0] >= 30 and b[0] >= s and b[1] <= e), reverse=True)
    late = [k + 1 for k, start in enumerate(meals[:need_meal]) if start > s + 300 * (k + 1)]
    need_rest = 0 if L < 210 else (L + 120) // 240
    rests = sum(1 for b in breaks if b[2] == 'rest' and b[1] - b[0] >= 10)
    return {'meals_required': need_meal, 'late': late, 'missing_meal': max(need_meal - len(meals), 0),
            'missing_rest': max(need_rest - rests, 0)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 3', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 4', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[1320, 2040], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 6', [[420, 780], [[540, 549, 'rest'], [980, 1025, 'meal'], [380, 425, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7', [[0, 480], [[560, 580, 'meal'], [300, 345, 'meal'], [270, 301, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 2', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 4',
   [[0, 360], [[120, 150, 'meal'], [340, 355, 'rest'], [60, 90, 'meal'], [600, 615, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 5', [[420, 1080], [[1020, 1051, 'meal']]],
   {'meals_required': 2, 'late': [1], 'missing_meal': 1, 'missing_rest': 3}),
  ('normal control 6',
   [[360, 1080], [[420, 430, 'meal'], [960, 970, 'rest'], [420, 430, 'meal'], [690, 699, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 2}),
  ('normal control 7', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 209], [[120, 140, 'meal'], [300, 315, 'rest'], [301, 310, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})],
 [('regression: meal order 1', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('regression variant: meal order 2', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 3',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('boundary control 4', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 5', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 480], [[-40, -30, 'rest'], [460, 475, 'rest'], [200, 215, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 7', [[1320, 1621], [[1590, 1621, 'meal'], [1920, 1935, 'meal'], [1280, 1311, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 8', [[0, 359], [[120, 149, 'meal'], [120, 135, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('partial repair guard 2', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 4',
   [[360, 1080], [[1060, 1070, 'rest'], [690, 705, 'rest'], [660, 691, 'meal'], [920, 949, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 5',
   [[0, 600], [[200, 215, 'rest'], [-40, -11, 'meal'], [120, 135, 'rest'], [60, 70, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 780], [[480, 490, 'rest'], [380, 400, 'meal'], [690, 699, 'meal'], [980, 990, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('partial repair guard 3',
   [[420, 1080], [[480, 511, 'meal'], [750, 780, 'meal'], [1020, 1051, 'meal'], [620, 629, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 4', [[1320, 1920], [[1600, 1629, 'meal'], [1450, 1460, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 5', [[1320, 1500], [[1280, 1295, 'rest'], [1650, 1679, 'meal'], [1480, 1490, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1530], [[1380, 1389, 'rest'], [1880, 1895, 'meal'], [1525, 1534, 'meal'], [1440, 1449, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7',
   [[360, 569], [[630, 659, 'meal'], [549, 578, 'meal'], [960, 989, 'meal'], [320, 335, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[1320, 1620], [[1440, 1470, 'meal'], [1620, 1640, 'meal'], [1650, 1665, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})]]
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: meal order 1{'late': [1], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}Failed
regression variant: meal order 2{'late': [1], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}Failed
boundary control 3{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 4{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}Passed
normal control 5{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed
normal control 6{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Passed
normal control 7{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}Passed
normal control 8{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Passed

SHA-256 / bbf8895d9575631c0109e4bf309207975313b2a10312dd0cf4de6c9cc399854d

3 / The verified repair

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

N = 1
observations = []
def solve(shift, breaks):
    s, e = shift
    L = e - s
    need_meal = (L > 300) + (L > 600)
    meals = sorted(b[0] for b in breaks if b[2] == 'meal' and b[1] - b[0] >= 30 and b[0] >= s and b[1] <= e)
    late = [k + 1 for k, start in enumerate(meals[:need_meal]) if start > s + 300 * (k + 1)]
    need_rest = 0 if L < 210 else (L + 120) // 240
    rests = sum(1 for b in breaks if b[2] == 'rest' and b[1] - b[0] >= 10)
    return {'meals_required': need_meal, 'late': late, 'missing_meal': max(need_meal - len(meals), 0),
            'missing_rest': max(need_rest - rests, 0)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 3', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 4', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[1320, 2040], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 6', [[420, 780], [[540, 549, 'rest'], [980, 1025, 'meal'], [380, 425, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7', [[0, 480], [[560, 580, 'meal'], [300, 345, 'meal'], [270, 301, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 2', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 4',
   [[0, 360], [[120, 150, 'meal'], [340, 355, 'rest'], [60, 90, 'meal'], [600, 615, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 5', [[420, 1080], [[1020, 1051, 'meal']]],
   {'meals_required': 2, 'late': [1], 'missing_meal': 1, 'missing_rest': 3}),
  ('normal control 6',
   [[360, 1080], [[420, 430, 'meal'], [960, 970, 'rest'], [420, 430, 'meal'], [690, 699, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 2}),
  ('normal control 7', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 209], [[120, 140, 'meal'], [300, 315, 'rest'], [301, 310, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})],
 [('regression: meal order 1', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('regression variant: meal order 2', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('partial repair guard 3',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('boundary control 4', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 5', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 480], [[-40, -30, 'rest'], [460, 475, 'rest'], [200, 215, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 7', [[1320, 1621], [[1590, 1621, 'meal'], [1920, 1935, 'meal'], [1280, 1311, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 8', [[0, 359], [[120, 149, 'meal'], [120, 135, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1',
   [[420, 779], [[540, 569, 'meal'], [721, 752, 'meal'], [720, 765, 'meal'], [720, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('partial repair guard 2', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 3', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 4',
   [[360, 1080], [[1060, 1070, 'rest'], [690, 705, 'rest'], [660, 691, 'meal'], [920, 949, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 5',
   [[0, 600], [[200, 215, 'rest'], [-40, -11, 'meal'], [120, 135, 'rest'], [60, 70, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 780], [[480, 490, 'rest'], [380, 400, 'meal'], [690, 699, 'meal'], [980, 990, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('normal control 8', [[360, 690], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal order 1', [[0, 700], [[400, 430, 'meal'], [200, 230, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal order 2',
   [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('partial repair guard 3',
   [[420, 1080], [[480, 511, 'meal'], [750, 780, 'meal'], [1020, 1051, 'meal'], [620, 629, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 4', [[1320, 1920], [[1600, 1629, 'meal'], [1450, 1460, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 5', [[1320, 1500], [[1280, 1295, 'rest'], [1650, 1679, 'meal'], [1480, 1490, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6',
   [[1320, 1530], [[1380, 1389, 'rest'], [1880, 1895, 'meal'], [1525, 1534, 'meal'], [1440, 1449, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7',
   [[360, 569], [[630, 659, 'meal'], [549, 578, 'meal'], [960, 989, 'meal'], [320, 335, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[1320, 1620], [[1440, 1470, 'meal'], [1620, 1640, 'meal'], [1650, 1665, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0})]]
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: meal order 1{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 3}Passed
regression variant: meal order 2{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 2, 'missing_meal': 0, 'missing_rest': 2}Passed
boundary control 3{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 4{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}Passed
normal control 5{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed
normal control 6{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Passed
normal control 7{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}Passed
normal control 8{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Passed

SHA-256 / f2e4a8cf8f2e8bbb1fead21fb0d1f294d880e60dd1fec91a9eb11b24d9c68fef

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:51:59.995133+00:00.

Case digest / 6bbc1a6b14f7eadbca27a52be9790ba82ad8ddad005d9fb413b8259f31df8532