FA-94026 / Shift rostering labor rules / Open access
Night overlap counted from window start even when the shift starts later · case 01
A shift starting at 01:00 is credited night minutes from 23:00.
ROOT CAUSE
The intersection start ignores the shift start.
VERIFIED REPAIR
Intersection starts at the later of shift start and window start.
Unsuccessful approach: Taking the earlier of the two starts overcounts the same way.
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 + 1):
lo = d * 1440 + 1380
hi = d * 1440 + 1800
night += max(0, min(e, hi) - lo)
return [night, night >= threshold]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: intersection start clip 1', [[120, 480], 180], [240, True]),
('regression variant: intersection start clip 2', [[3780, 4068], 120], [0, False]),
('partial repair guard 3', [[1800, 2400], 180], [0, False]),
('boundary control 4', [[1380, 1559], 180], [179, False]),
('boundary control 5', [[1320, 1800], 180], [420, True]),
('normal control 6', [[3960, 4560], 120], [300, True]),
('normal control 7', [[20, 200], 240], [180, False]),
('normal control 8', [[360, 1160], 120], [0, False])],
[('regression: intersection start clip 1', [[1320, 1800], 180], [420, True]),
('regression variant: intersection start clip 2', [[4200, 4380], 180], [120, False]),
('partial repair guard 3', [[4680, 5400], 180], [0, False]),
('boundary control 4', [[1800, 2400], 180], [0, False]),
('boundary control 5', [[900, 1410], 180], [30, False]),
('normal control 6', [[1010, 1040], 180], [0, False]),
('normal control 7', [[4200, 4920], 120], [420, True]),
('normal control 8', [[5880, 6360], 120], [240, True])],
[('regression: intersection start clip 1', [[1380, 1560], 180], [180, True]),
('regression variant: intersection start clip 2', [[4200, 4230], 120], [0, False]),
('partial repair guard 3', [[1560, 2040], 120], [240, True]),
('boundary control 4', [[120, 480], 180], [240, True]),
('normal control 5', [[360, 1222], 180], [0, False]), ('normal control 6', [[3240, 3540], 120], [0, False]),
('normal control 7', [[4680, 4710], 180], [0, False]),
('normal control 8', [[2700, 3055], 180], [235, True])],
[('regression: intersection start clip 1', [[1380, 1559], 180], [179, False]),
('regression variant: intersection start clip 2', [[8051, 8771], 180], [191, True]),
('partial repair guard 3', [[3000, 3600], 240], [240, True]),
('boundary control 4', [[2940, 3300], 240], [300, True]),
('normal control 5', [[3780, 4380], 180], [120, False]),
('normal control 6', [[3960, 4140], 240], [0, False]), ('normal control 7', [[414, 594], 240], [0, False]),
('normal control 8', [[3808, 3838], 240], [0, False])],
[('regression: intersection start clip 1', [[900, 1410], 180], [30, False]),
('regression variant: intersection start clip 2', [[1400, 2000], 120], [400, True]),
('partial repair guard 3', [[2840, 3020], 240], [180, False]),
('boundary control 4', [[1320, 1800], 180], [420, True]),
('boundary control 5', [[1800, 2400], 180], [0, False]),
('normal control 6', [[4740, 4980], 180], [0, False]),
('normal control 7', [[1260, 2159], 240], [420, True]),
('normal control 8', [[7320, 8040], 180], [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: intersection start clip 1 | [420, True] | [240, True] | Failed |
| regression variant: intersection start clip 2 | [420, True] | [0, False] | Failed |
| partial repair guard 3 | [420, True] | [0, False] | Failed |
| boundary control 4 | [599, True] | [179, False] | Failed |
| boundary control 5 | [840, True] | [420, True] | Failed |
| normal control 6 | [720, True] | [300, True] | Failed |
| normal control 7 | [260, True] | [180, False] | Failed |
| normal control 8 | [420, True] | [0, False] | Failed |
SHA-256 / 05aa144924f8dd0f0b45d6975390b71cb7202883240864e4b8eea93a0383b76d
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 // 1440 + 1):
lo = d * 1440 + 1380
hi = d * 1440 + 1800
night += max(0, min(e, hi) - min(s, lo))
return [night, night >= threshold]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: intersection start clip 1', [[120, 480], 180], [240, True]),
('regression variant: intersection start clip 2', [[3780, 4068], 120], [0, False]),
('partial repair guard 3', [[1800, 2400], 180], [0, False]),
('boundary control 4', [[1380, 1559], 180], [179, False]),
('boundary control 5', [[1320, 1800], 180], [420, True]),
('normal control 6', [[3960, 4560], 120], [300, True]),
('normal control 7', [[20, 200], 240], [180, False]),
('normal control 8', [[360, 1160], 120], [0, False])],
[('regression: intersection start clip 1', [[1320, 1800], 180], [420, True]),
('regression variant: intersection start clip 2', [[4200, 4380], 180], [120, False]),
('partial repair guard 3', [[4680, 5400], 180], [0, False]),
('boundary control 4', [[1800, 2400], 180], [0, False]),
('boundary control 5', [[900, 1410], 180], [30, False]),
('normal control 6', [[1010, 1040], 180], [0, False]),
('normal control 7', [[4200, 4920], 120], [420, True]),
('normal control 8', [[5880, 6360], 120], [240, True])],
[('regression: intersection start clip 1', [[1380, 1560], 180], [180, True]),
('regression variant: intersection start clip 2', [[4200, 4230], 120], [0, False]),
('partial repair guard 3', [[1560, 2040], 120], [240, True]),
('boundary control 4', [[120, 480], 180], [240, True]),
('normal control 5', [[360, 1222], 180], [0, False]), ('normal control 6', [[3240, 3540], 120], [0, False]),
('normal control 7', [[4680, 4710], 180], [0, False]),
('normal control 8', [[2700, 3055], 180], [235, True])],
[('regression: intersection start clip 1', [[1380, 1559], 180], [179, False]),
('regression variant: intersection start clip 2', [[8051, 8771], 180], [191, True]),
('partial repair guard 3', [[3000, 3600], 240], [240, True]),
('boundary control 4', [[2940, 3300], 240], [300, True]),
('normal control 5', [[3780, 4380], 180], [120, False]),
('normal control 6', [[3960, 4140], 240], [0, False]), ('normal control 7', [[414, 594], 240], [0, False]),
('normal control 8', [[3808, 3838], 240], [0, False])],
[('regression: intersection start clip 1', [[900, 1410], 180], [30, False]),
('regression variant: intersection start clip 2', [[1400, 2000], 120], [400, True]),
('partial repair guard 3', [[2840, 3020], 240], [180, False]),
('boundary control 4', [[1320, 1800], 180], [420, True]),
('boundary control 5', [[1800, 2400], 180], [0, False]),
('normal control 6', [[4740, 4980], 180], [0, False]),
('normal control 7', [[1260, 2159], 240], [420, True]),
('normal control 8', [[7320, 8040], 180], [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: intersection start clip 1 | [780, True] | [240, True] | Failed |
| regression variant: intersection start clip 2 | [708, True] | [0, False] | Failed |
| partial repair guard 3 | [1020, True] | [0, False] | Failed |
| boundary control 4 | [778, True] | [179, False] | Failed |
| boundary control 5 | [1380, True] | [420, True] | Failed |
| normal control 6 | [1620, True] | [300, True] | Failed |
| normal control 7 | [440, True] | [180, False] | Failed |
| normal control 8 | [1220, True] | [0, False] | Failed |
SHA-256 / b0a9f18e7c821980c0d4b670488dc879b7f839105ceeba1053d10f8003399913
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: intersection start clip 1', [[120, 480], 180], [240, True]),
('regression variant: intersection start clip 2', [[3780, 4068], 120], [0, False]),
('partial repair guard 3', [[1800, 2400], 180], [0, False]),
('boundary control 4', [[1380, 1559], 180], [179, False]),
('boundary control 5', [[1320, 1800], 180], [420, True]),
('normal control 6', [[3960, 4560], 120], [300, True]),
('normal control 7', [[20, 200], 240], [180, False]),
('normal control 8', [[360, 1160], 120], [0, False])],
[('regression: intersection start clip 1', [[1320, 1800], 180], [420, True]),
('regression variant: intersection start clip 2', [[4200, 4380], 180], [120, False]),
('partial repair guard 3', [[4680, 5400], 180], [0, False]),
('boundary control 4', [[1800, 2400], 180], [0, False]),
('boundary control 5', [[900, 1410], 180], [30, False]),
('normal control 6', [[1010, 1040], 180], [0, False]),
('normal control 7', [[4200, 4920], 120], [420, True]),
('normal control 8', [[5880, 6360], 120], [240, True])],
[('regression: intersection start clip 1', [[1380, 1560], 180], [180, True]),
('regression variant: intersection start clip 2', [[4200, 4230], 120], [0, False]),
('partial repair guard 3', [[1560, 2040], 120], [240, True]),
('boundary control 4', [[120, 480], 180], [240, True]),
('normal control 5', [[360, 1222], 180], [0, False]), ('normal control 6', [[3240, 3540], 120], [0, False]),
('normal control 7', [[4680, 4710], 180], [0, False]),
('normal control 8', [[2700, 3055], 180], [235, True])],
[('regression: intersection start clip 1', [[1380, 1559], 180], [179, False]),
('regression variant: intersection start clip 2', [[8051, 8771], 180], [191, True]),
('partial repair guard 3', [[3000, 3600], 240], [240, True]),
('boundary control 4', [[2940, 3300], 240], [300, True]),
('normal control 5', [[3780, 4380], 180], [120, False]),
('normal control 6', [[3960, 4140], 240], [0, False]), ('normal control 7', [[414, 594], 240], [0, False]),
('normal control 8', [[3808, 3838], 240], [0, False])],
[('regression: intersection start clip 1', [[900, 1410], 180], [30, False]),
('regression variant: intersection start clip 2', [[1400, 2000], 120], [400, True]),
('partial repair guard 3', [[2840, 3020], 240], [180, False]),
('boundary control 4', [[1320, 1800], 180], [420, True]),
('boundary control 5', [[1800, 2400], 180], [0, False]),
('normal control 6', [[4740, 4980], 180], [0, False]),
('normal control 7', [[1260, 2159], 240], [420, True]),
('normal control 8', [[7320, 8040], 180], [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: intersection start clip 1 | [240, True] | [240, True] | Passed |
| regression variant: intersection start clip 2 | [0, False] | [0, False] | Passed |
| partial repair guard 3 | [0, False] | [0, False] | Passed |
| boundary control 4 | [179, False] | [179, False] | Passed |
| boundary control 5 | [420, True] | [420, True] | Passed |
| normal control 6 | [300, True] | [300, True] | Passed |
| normal control 7 | [180, False] | [180, False] | Passed |
| normal control 8 | [0, False] | [0, False] | Passed |
SHA-256 / 4166933d680e631201cc455bddeef1f8795e981b29207aae5e6ce01d37ea1004
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.632911+00:00.
Case digest / b84a917c426633094f518e6ff19af81671bd26232a3bdbe4210c2fccc8cbea02