FAILURE MAP
← Case archive

FA-93951 / Shift rostering labor rules / Open access

Meal logged outside the shift satisfies the entitlement · case 01

A meal taken before clock-in or after clock-out cancels the missing-meal finding.

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

ROOT CAUSE

Meals are counted without checking they lie within the shift.

VERIFIED REPAIR

Count only meals whose whole interval lies inside the shift.

Unsuccessful approach: Checking only the meal start still counts a meal that runs past clock-out.

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 = sorted(b[0] for b in breaks if b[2] == 'meal' and b[1] - b[0] >= 30)
    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 outside shift 1', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2',
   [[1320, 1800], [[1880, 1909, 'meal'], [1380, 1389, 'meal'], [1621, 1650, 'meal'], [1780, 1811, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('partial repair guard 3', [[360, 840], [[820, 850, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 5', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[420, 630], [[610, 620, 'meal'], [610, 639, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[1320, 1921], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[1320, 1980], [[1621, 1636, 'rest'], [1960, 1970, 'rest'], [1280, 1311, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1}),
  ('partial repair guard 3', [[1320, 1680], [[1675, 1705, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('boundary control 5', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 180], [[270, 280, 'meal'], [160, 191, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[420, 779], [[774, 805, 'meal'], [774, 783, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8',
   [[0, 330], [[301, 316, 'meal'], [290, 299, 'rest'], [310, 355, 'meal'], [200, 231, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1})],
 [('regression: meal outside shift 1',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('regression variant: meal outside shift 2',
   [[420, 1020], [[1000, 1031, 'meal'], [380, 389, 'rest'], [380, 395, 'meal'], [480, 490, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 3', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 4', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6', [[0, 301], [[120, 135, 'meal'], [560, 590, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1529], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 359], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal outside shift 1', [[420, 750], [[380, 410, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('partial repair guard 3',
   [[420, 721], [[710, 741, 'meal'], [750, 759, 'meal'], [1020, 1030, 'rest'], [720, 729, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('boundary control 4', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 5', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 6', [[1320, 1680], [[1440, 1460, 'meal'], [1280, 1289, 'rest'], [1660, 1670, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 721], [[721, 741, 'meal'], [750, 760, 'meal'], [710, 719, 'rest'], [380, 390, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[0, 660], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1',
   [[1320, 2040], [[1280, 1300, 'meal'], [1880, 1889, 'meal'], [1280, 1325, 'meal'], [1280, 1290, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[0, 359], [[560, 570, 'meal'], [120, 130, 'meal'], [600, 645, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('boundary control 3', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('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, 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 6', [[0, 180], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[0, 720], [[290, 299, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 8', [[360, 1080], [[320, 365, 'meal'], [630, 645, 'rest'], [630, 645, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1})]]
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 outside shift 1{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Failed
regression variant: meal outside shift 2{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Failed
partial repair guard 3{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Failed
boundary control 4{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 5{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 3}Failed
normal control 6{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}Passed
normal control 7{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Failed
normal control 8{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed

SHA-256 / e5a5fcccd6ca83ca5d58028940be200a5aa2e3adbffe550603e564d0f852a2d3

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)
    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 outside shift 1', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2',
   [[1320, 1800], [[1880, 1909, 'meal'], [1380, 1389, 'meal'], [1621, 1650, 'meal'], [1780, 1811, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('partial repair guard 3', [[360, 840], [[820, 850, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 5', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[420, 630], [[610, 620, 'meal'], [610, 639, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[1320, 1921], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[1320, 1980], [[1621, 1636, 'rest'], [1960, 1970, 'rest'], [1280, 1311, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1}),
  ('partial repair guard 3', [[1320, 1680], [[1675, 1705, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('boundary control 5', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 180], [[270, 280, 'meal'], [160, 191, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[420, 779], [[774, 805, 'meal'], [774, 783, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8',
   [[0, 330], [[301, 316, 'meal'], [290, 299, 'rest'], [310, 355, 'meal'], [200, 231, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1})],
 [('regression: meal outside shift 1',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('regression variant: meal outside shift 2',
   [[420, 1020], [[1000, 1031, 'meal'], [380, 389, 'rest'], [380, 395, 'meal'], [480, 490, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 3', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 4', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6', [[0, 301], [[120, 135, 'meal'], [560, 590, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1529], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 359], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal outside shift 1', [[420, 750], [[380, 410, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('partial repair guard 3',
   [[420, 721], [[710, 741, 'meal'], [750, 759, 'meal'], [1020, 1030, 'rest'], [720, 729, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('boundary control 4', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 5', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 6', [[1320, 1680], [[1440, 1460, 'meal'], [1280, 1289, 'rest'], [1660, 1670, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 721], [[721, 741, 'meal'], [750, 760, 'meal'], [710, 719, 'rest'], [380, 390, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[0, 660], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1',
   [[1320, 2040], [[1280, 1300, 'meal'], [1880, 1889, 'meal'], [1280, 1325, 'meal'], [1280, 1290, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[0, 359], [[560, 570, 'meal'], [120, 130, 'meal'], [600, 645, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('boundary control 3', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('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, 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 6', [[0, 180], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[0, 720], [[290, 299, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 8', [[360, 1080], [[320, 365, 'meal'], [630, 645, 'rest'], [630, 645, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1})]]
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 outside shift 1{'late': [], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Failed
regression variant: meal outside shift 2{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Failed
partial repair guard 3{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Failed
boundary control 4{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 5{'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 6{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}Passed
normal control 7{'late': [1], 'meals_required': 1, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Failed
normal control 8{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed

SHA-256 / 170011f61b017dc87dbfb792861b144f090436330df135a484b2b57c721c8f36

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 outside shift 1', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2',
   [[1320, 1800], [[1880, 1909, 'meal'], [1380, 1389, 'meal'], [1621, 1650, 'meal'], [1780, 1811, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('partial repair guard 3', [[360, 840], [[820, 850, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[420, 1021], [[600, 630, 'meal'], [1000, 1021, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 3}),
  ('boundary control 5', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[420, 630], [[610, 620, 'meal'], [610, 639, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[1320, 1921], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1', [[0, 600], [[-40, -10, 'meal'], [330, 360, 'meal']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[1320, 1980], [[1621, 1636, 'rest'], [1960, 1970, 'rest'], [1280, 1311, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1}),
  ('partial repair guard 3', [[1320, 1680], [[1675, 1705, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 4', [[0, 210], [[100, 110, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('boundary control 5', [[60, 720], [[200, 230, 'meal'], [500, 530, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 6', [[0, 180], [[270, 280, 'meal'], [160, 191, 'meal']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[420, 779], [[774, 805, 'meal'], [774, 783, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8',
   [[0, 330], [[301, 316, 'meal'], [290, 299, 'rest'], [310, 355, 'meal'], [200, 231, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 0, 'missing_rest': 1})],
 [('regression: meal outside shift 1',
   [[1320, 1921], [[1901, 1932, 'meal'], [1590, 1635, 'meal'], [1380, 1395, 'rest'], [1901, 1946, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('regression variant: meal outside shift 2',
   [[420, 1020], [[1000, 1031, 'meal'], [380, 389, 'rest'], [380, 395, 'meal'], [480, 490, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('boundary control 3', [[0, 480], [[310, 340, 'meal'], [100, 109, 'rest']]],
   {'meals_required': 1, 'late': [1], 'missing_meal': 0, 'missing_rest': 2}),
  ('boundary control 4', [[100, 800], [[600, 630, 'meal'], [300, 330, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('normal control 5', [[360, 569], [[690, 720, 'meal'], [564, 573, 'rest']]],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 6', [[0, 301], [[120, 135, 'meal'], [560, 590, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 7', [[1320, 1529], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 8', [[0, 359], []],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1})],
 [('regression: meal outside shift 1', [[420, 750], [[380, 410, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('regression variant: meal outside shift 2', [[1320, 1650], [[1590, 1599, 'meal'], [1621, 1652, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('partial repair guard 3',
   [[420, 721], [[710, 741, 'meal'], [750, 759, 'meal'], [1020, 1030, 'rest'], [720, 729, 'rest']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 0}),
  ('boundary control 4', [[0, 660], [[250, 280, 'meal'], [590, 620, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 3}),
  ('boundary control 5', [[420, 721], [[700, 730, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 6', [[1320, 1680], [[1440, 1460, 'meal'], [1280, 1289, 'rest'], [1660, 1670, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 2}),
  ('normal control 7',
   [[420, 721], [[721, 741, 'meal'], [750, 760, 'meal'], [710, 719, 'rest'], [380, 390, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('normal control 8', [[0, 660], []],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3})],
 [('regression: meal outside shift 1',
   [[1320, 2040], [[1280, 1300, 'meal'], [1880, 1889, 'meal'], [1280, 1325, 'meal'], [1280, 1290, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('regression variant: meal outside shift 2',
   [[0, 359], [[560, 570, 'meal'], [120, 130, 'meal'], [600, 645, 'meal']]],
   {'meals_required': 1, 'late': [], 'missing_meal': 1, 'missing_rest': 1}),
  ('boundary control 3', [[0, 650], [[550, 580, 'rest'], [500, 530, 'meal'], [250, 280, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 0, 'missing_rest': 2}),
  ('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, 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 6', [[0, 180], []],
   {'meals_required': 0, 'late': [], 'missing_meal': 0, 'missing_rest': 0}),
  ('normal control 7', [[0, 720], [[290, 299, 'meal']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 3}),
  ('normal control 8', [[360, 1080], [[320, 365, 'meal'], [630, 645, 'rest'], [630, 645, 'rest']]],
   {'meals_required': 2, 'late': [], 'missing_meal': 2, 'missing_rest': 1})]]
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 outside shift 1{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Passed
regression variant: meal outside shift 2{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Passed
partial repair guard 3{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 2}Passed
boundary control 4{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 1, 'missing_rest': 3}Passed
boundary control 5{'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 6{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}{'late': [], 'meals_required': 0, 'missing_meal': 0, 'missing_rest': 1}Passed
normal control 7{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}{'late': [], 'meals_required': 1, 'missing_meal': 1, 'missing_rest': 1}Passed
normal control 8{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}{'late': [], 'meals_required': 2, 'missing_meal': 2, 'missing_rest': 3}Passed

SHA-256 / 5167fbdaed37cede20a5b506d4acf455560d81d19363bedd7e4432e8e10a9645

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

Case digest / 9003b9b2b0269a29a8b10679d6d139a3f926a783a5af1ff40b905cd257e1019e