FAILURE MAP
← Case archive

FA-94016 / Shift rostering labor rules / Open access

Late-evening minutes on the shift end day are ignored · case 01

A shift ending at 23:30 loses its last 30 night minutes.

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

ROOT CAUSE

The night window that opens on the end day is not enumerated.

VERIFIED REPAIR

Enumerate windows through the shift end day.

Unsuccessful approach: Bounding by the start day misses windows of multi-day shifts.

Case contract

A shift [start, end] in absolute minutes (day 0 starts at minute 0) and a night-shift threshold. The night period runs 23:00 to 06:00 across midnight. Return [night minutes, whether night minutes reach the threshold].

Why this case matters

Night-work classification drives night-worker limits and premiums and must handle shifts that start after midnight.

1 / The failure

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

N = 1
observations = []
def solve(shift, threshold):
    s, e = shift
    night = 0
    for d in range(s // 1440 - 1, e // 1440):
        lo = d * 1440 + 1380
        hi = d * 1440 + 1800
        night += max(0, min(e, hi) - max(s, lo))
    return [night, night >= threshold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: final day window 1', [[900, 1410], 180], [30, False]),
  ('regression variant: final day window 2', [[2820, 2850], 180], [30, False]),
  ('partial repair guard 3', [[4102, 4282], 180], [22, False]),
  ('boundary control 4', [[1380, 1559], 180], [179, False]),
  ('boundary control 5', [[1320, 1800], 180], [420, True]),
  ('normal control 6', [[4260, 4740], 240], [420, True]),
  ('normal control 7', [[3240, 3359], 120], [0, False]),
  ('normal control 8', [[7020, 7260], 120], [120, True])],
 [('regression: final day window 1', [[2820, 2850], 120], [30, False]),
  ('partial repair guard 2', [[5580, 5760], 240], [60, False]),
  ('boundary control 3', [[1800, 2400], 180], [0, False]),
  ('boundary control 4', [[900, 1410], 180], [30, False]),
  ('normal control 5', [[4740, 5404], 240], [0, False]),
  ('normal control 6', [[5760, 5940], 240], [180, False]),
  ('normal control 7', [[4320, 4500], 120], [180, True]),
  ('normal control 8', [[6060, 6780], 240], [60, False])],
 [('regression: final day window 1', [[8554, 8584], 120], [4, False]),
  ('regression variant: final day window 2', [[2840, 2870], 240], [30, False]),
  ('partial repair guard 3', [[5700, 5730], 120], [30, False]),
  ('boundary control 4', [[1380, 1560], 180], [180, True]),
  ('boundary control 5', [[120, 480], 180], [240, True]),
  ('normal control 6', [[1440, 1620], 240], [180, False]),
  ('normal control 7', [[1400, 2120], 180], [400, True]),
  ('normal control 8', [[2880, 3060], 180], [180, True])],
 [('regression: final day window 1', [[4260, 4290], 120], [30, False]),
  ('regression variant: final day window 2', [[1400, 1430], 180], [30, False]),
  ('partial repair guard 3', [[900, 1410], 180], [30, False]),
  ('boundary control 4', [[2940, 3300], 240], [300, True]),
  ('boundary control 5', [[1380, 1559], 180], [179, False]),
  ('normal control 6', [[1800, 2400], 240], [0, False]),
  ('normal control 7', [[3960, 4560], 120], [300, True]),
  ('normal control 8', [[4102, 4282], 180], [22, False])],
 [('regression: final day window 1', [[8580, 8610], 120], [30, False]),
  ('regression variant: final day window 2', [[7160, 7190], 180], [30, False]),
  ('boundary control 3', [[1320, 1800], 180], [420, True]),
  ('boundary control 4', [[1800, 2400], 180], [0, False]),
  ('normal control 5', [[1380, 1410], 180], [30, False]),
  ('normal control 6', [[3240, 3511], 120], [0, False]), ('normal control 7', [[420, 900], 180], [0, False]),
  ('normal control 8', [[4280, 4520], 240], [240, True])]]
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: final day window 1[0, False][30, False]Failed
regression variant: final day window 2[0, False][30, False]Failed
partial repair guard 3[0, False][22, False]Failed
boundary control 4[179, False][179, False]Passed
boundary control 5[420, True][420, True]Passed
normal control 6[420, True][420, True]Passed
normal control 7[0, False][0, False]Passed
normal control 8[120, True][120, True]Passed

SHA-256 / e3ffd6755a54b644ac5d15da1aa21a813195c8112bd61292063b29b99e70051f

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shift, threshold):
    s, e = shift
    night = 0
    for d in range(s // 1440 - 1, (e - 1) // 1440):
        lo = d * 1440 + 1380
        hi = d * 1440 + 1800
        night += max(0, min(e, hi) - max(s, lo))
    return [night, night >= threshold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: final day window 1', [[900, 1410], 180], [30, False]),
  ('regression variant: final day window 2', [[2820, 2850], 180], [30, False]),
  ('partial repair guard 3', [[4102, 4282], 180], [22, False]),
  ('boundary control 4', [[1380, 1559], 180], [179, False]),
  ('boundary control 5', [[1320, 1800], 180], [420, True]),
  ('normal control 6', [[4260, 4740], 240], [420, True]),
  ('normal control 7', [[3240, 3359], 120], [0, False]),
  ('normal control 8', [[7020, 7260], 120], [120, True])],
 [('regression: final day window 1', [[2820, 2850], 120], [30, False]),
  ('partial repair guard 2', [[5580, 5760], 240], [60, False]),
  ('boundary control 3', [[1800, 2400], 180], [0, False]),
  ('boundary control 4', [[900, 1410], 180], [30, False]),
  ('normal control 5', [[4740, 5404], 240], [0, False]),
  ('normal control 6', [[5760, 5940], 240], [180, False]),
  ('normal control 7', [[4320, 4500], 120], [180, True]),
  ('normal control 8', [[6060, 6780], 240], [60, False])],
 [('regression: final day window 1', [[8554, 8584], 120], [4, False]),
  ('regression variant: final day window 2', [[2840, 2870], 240], [30, False]),
  ('partial repair guard 3', [[5700, 5730], 120], [30, False]),
  ('boundary control 4', [[1380, 1560], 180], [180, True]),
  ('boundary control 5', [[120, 480], 180], [240, True]),
  ('normal control 6', [[1440, 1620], 240], [180, False]),
  ('normal control 7', [[1400, 2120], 180], [400, True]),
  ('normal control 8', [[2880, 3060], 180], [180, True])],
 [('regression: final day window 1', [[4260, 4290], 120], [30, False]),
  ('regression variant: final day window 2', [[1400, 1430], 180], [30, False]),
  ('partial repair guard 3', [[900, 1410], 180], [30, False]),
  ('boundary control 4', [[2940, 3300], 240], [300, True]),
  ('boundary control 5', [[1380, 1559], 180], [179, False]),
  ('normal control 6', [[1800, 2400], 240], [0, False]),
  ('normal control 7', [[3960, 4560], 120], [300, True]),
  ('normal control 8', [[4102, 4282], 180], [22, False])],
 [('regression: final day window 1', [[8580, 8610], 120], [30, False]),
  ('regression variant: final day window 2', [[7160, 7190], 180], [30, False]),
  ('boundary control 3', [[1320, 1800], 180], [420, True]),
  ('boundary control 4', [[1800, 2400], 180], [0, False]),
  ('normal control 5', [[1380, 1410], 180], [30, False]),
  ('normal control 6', [[3240, 3511], 120], [0, False]), ('normal control 7', [[420, 900], 180], [0, False]),
  ('normal control 8', [[4280, 4520], 240], [240, True])]]
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: final day window 1[0, False][30, False]Failed
regression variant: final day window 2[0, False][30, False]Failed
partial repair guard 3[0, False][22, False]Failed
boundary control 4[179, False][179, False]Passed
boundary control 5[420, True][420, True]Passed
normal control 6[420, True][420, True]Passed
normal control 7[0, False][0, False]Passed
normal control 8[120, True][120, True]Passed

SHA-256 / cad85a89a87932551615b856dffd8b0fbd3fcacf6b3368ea64c3190082b4c46f

3 / The verified repair

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

N = 1
observations = []
def solve(shift, threshold):
    s, e = shift
    night = 0
    for d in range(s // 1440 - 1, e // 1440 + 1):
        lo = d * 1440 + 1380
        hi = d * 1440 + 1800
        night += max(0, min(e, hi) - max(s, lo))
    return [night, night >= threshold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: final day window 1', [[900, 1410], 180], [30, False]),
  ('regression variant: final day window 2', [[2820, 2850], 180], [30, False]),
  ('partial repair guard 3', [[4102, 4282], 180], [22, False]),
  ('boundary control 4', [[1380, 1559], 180], [179, False]),
  ('boundary control 5', [[1320, 1800], 180], [420, True]),
  ('normal control 6', [[4260, 4740], 240], [420, True]),
  ('normal control 7', [[3240, 3359], 120], [0, False]),
  ('normal control 8', [[7020, 7260], 120], [120, True])],
 [('regression: final day window 1', [[2820, 2850], 120], [30, False]),
  ('partial repair guard 2', [[5580, 5760], 240], [60, False]),
  ('boundary control 3', [[1800, 2400], 180], [0, False]),
  ('boundary control 4', [[900, 1410], 180], [30, False]),
  ('normal control 5', [[4740, 5404], 240], [0, False]),
  ('normal control 6', [[5760, 5940], 240], [180, False]),
  ('normal control 7', [[4320, 4500], 120], [180, True]),
  ('normal control 8', [[6060, 6780], 240], [60, False])],
 [('regression: final day window 1', [[8554, 8584], 120], [4, False]),
  ('regression variant: final day window 2', [[2840, 2870], 240], [30, False]),
  ('partial repair guard 3', [[5700, 5730], 120], [30, False]),
  ('boundary control 4', [[1380, 1560], 180], [180, True]),
  ('boundary control 5', [[120, 480], 180], [240, True]),
  ('normal control 6', [[1440, 1620], 240], [180, False]),
  ('normal control 7', [[1400, 2120], 180], [400, True]),
  ('normal control 8', [[2880, 3060], 180], [180, True])],
 [('regression: final day window 1', [[4260, 4290], 120], [30, False]),
  ('regression variant: final day window 2', [[1400, 1430], 180], [30, False]),
  ('partial repair guard 3', [[900, 1410], 180], [30, False]),
  ('boundary control 4', [[2940, 3300], 240], [300, True]),
  ('boundary control 5', [[1380, 1559], 180], [179, False]),
  ('normal control 6', [[1800, 2400], 240], [0, False]),
  ('normal control 7', [[3960, 4560], 120], [300, True]),
  ('normal control 8', [[4102, 4282], 180], [22, False])],
 [('regression: final day window 1', [[8580, 8610], 120], [30, False]),
  ('regression variant: final day window 2', [[7160, 7190], 180], [30, False]),
  ('boundary control 3', [[1320, 1800], 180], [420, True]),
  ('boundary control 4', [[1800, 2400], 180], [0, False]),
  ('normal control 5', [[1380, 1410], 180], [30, False]),
  ('normal control 6', [[3240, 3511], 120], [0, False]), ('normal control 7', [[420, 900], 180], [0, False]),
  ('normal control 8', [[4280, 4520], 240], [240, True])]]
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: final day window 1[30, False][30, False]Passed
regression variant: final day window 2[30, False][30, False]Passed
partial repair guard 3[22, False][22, False]Passed
boundary control 4[179, False][179, False]Passed
boundary control 5[420, True][420, True]Passed
normal control 6[420, True][420, True]Passed
normal control 7[0, False][0, False]Passed
normal control 8[120, True][120, True]Passed

SHA-256 / ae7bd835c69a75078e3db10f4df0d16053551396a118baf62957423edc2040bf

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

Case digest / 097b7c4f557a5d321a84d22532eed0d3a26202c500840a471939114a20f5ae09