FAILURE MAP
← Case archive

FA-94041 / Shift rostering labor rules / Open access

Weekend detection assumes a Sunday-first week · case 01

Monday minutes receive the weekend premium and Saturday minutes do not.

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

ROOT CAUSE

Day indices are interpreted with Sunday as day 0.

VERIFIED REPAIR

With Monday as day 0, Saturday and Sunday are days 5 and 6.

Unsuccessful approach: Checking only day 6 still drops Saturday.

Case contract

Shift [start, end] in minutes from Monday 00:00 and a base rate in cents per hour. Each minute earns base * (100 + pct) / 6000 cents where pct is 10 for 15:00-23:00, 15 for 23:00-07:00, else 0; on Saturday and Sunday (days 5 and 6) pct is the larger of that value and 12 (differentials do not stack). The exact total is rounded half up to a cent once.

Why this case matters

Shift differential calculations are where roster data meets payroll; stacking and day attribution errors are common.

1 / The failure

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

N = 1
observations = []
def solve(shift, base):
    s, e = shift
    total = 0
    for t in range(s, e):
        day = (t // 1440) % 7
        m = t % 1440
        pct = 0
        if 900 <= m < 1380:
            pct = 10
        if m >= 1380 or m < 420:
            pct = 15
        if day in (0, 6):
            pct = max(pct, 12)
        total += base * (100 + pct)
    return (total + 3000) // 6000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekend day index 1', [[900, 960], 1800], 1980),
  ('regression variant: weekend day index 2', [[7140, 7860], 1999], 27346),
  ('partial repair guard 3', [[7080, 7680], 90], 1028), ('boundary control 4', [[8580, 8700], 2000], 4600),
  ('normal control 5', [[7560, 7620], 1999], 2299), ('normal control 6', [[2820, 3420], 1800], 20160),
  ('normal control 7', [[360, 840], 90], 734), ('normal control 8', [[3621, 4018], 2000], 14027)],
 [('regression: weekend day index 1', [[7200, 7800], 2000], 22820),
  ('regression variant: weekend day index 2', [[900, 1140], 1999], 8796),
  ('partial repair guard 3', [[8040, 8100], 1999], 2239), ('boundary control 4', [[0, 3], 10], 1),
  ('boundary control 5', [[8580, 8700], 2000], 4600), ('normal control 6', [[9068, 9123], 1800], 1848),
  ('normal control 7', [[2820, 3420], 1800], 20160), ('normal control 8', [[3240, 3953], 2150], 26492)],
 [('regression: weekend day index 1', [[1320, 1500], 60], 204),
  ('regression variant: weekend day index 2', [[7560, 8069], 1999], 19053),
  ('partial repair guard 3', [[8160, 8760], 60], 677), ('boundary control 4', [[6600, 7260], 2000], 24200),
  ('boundary control 5', [[0, 3], 10], 1), ('normal control 6', [[4740, 4980], 60], 240),
  ('normal control 7', [[7140, 7860], 1800], 24624), ('normal control 8', [[3840, 4320], 2000], 17700)],
 [('regression: weekend day index 1', [[480, 960], 1999], 16192),
  ('regression variant: weekend day index 2', [[7560, 8280], 1999], 26927),
  ('partial repair guard 3', [[8040, 8280], 90], 403), ('boundary control 4', [[1320, 1500], 60], 204),
  ('boundary control 5', [[6600, 7260], 2000], 24200), ('normal control 6', [[1320, 1920], 2000], 22600),
  ('normal control 7', [[5220, 5502], 60], 310), ('normal control 8', [[8313, 8373], 60], 67)],
 [('regression: weekend day index 1', [[7958, 8472], 1999], 19180),
  ('regression variant: weekend day index 2', [[10020, 10740], 90], 1188),
  ('partial repair guard 3', [[8160, 8880], 60], 815), ('boundary control 4', [[480, 960], 1999], 16192),
  ('boundary control 5', [[1320, 1500], 60], 204), ('normal control 6', [[5760, 6000], 2000], 9200),
  ('normal control 7', [[6660, 6720], 2150], 2365), ('normal control 8', [[4740, 5460], 2000], 24800)]]
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: weekend day index 120161980Failed
regression variant: weekend day index 22638727346Failed
partial repair guard 310171028Failed
boundary control 446004600Passed
normal control 522992299Passed
normal control 62016020160Passed
normal control 7809734Failed
normal control 81402714027Passed

SHA-256 / 9a7528b182f45586f8b1b4ab47df9ec27f77603e720c046f169da16f038f159d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(shift, base):
    s, e = shift
    total = 0
    for t in range(s, e):
        day = (t // 1440) % 7
        m = t % 1440
        pct = 0
        if 900 <= m < 1380:
            pct = 10
        if m >= 1380 or m < 420:
            pct = 15
        if day >= 6:
            pct = max(pct, 12)
        total += base * (100 + pct)
    return (total + 3000) // 6000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekend day index 1', [[900, 960], 1800], 1980),
  ('regression variant: weekend day index 2', [[7140, 7860], 1999], 27346),
  ('partial repair guard 3', [[7080, 7680], 90], 1028), ('boundary control 4', [[8580, 8700], 2000], 4600),
  ('normal control 5', [[7560, 7620], 1999], 2299), ('normal control 6', [[2820, 3420], 1800], 20160),
  ('normal control 7', [[360, 840], 90], 734), ('normal control 8', [[3621, 4018], 2000], 14027)],
 [('regression: weekend day index 1', [[7200, 7800], 2000], 22820),
  ('regression variant: weekend day index 2', [[900, 1140], 1999], 8796),
  ('partial repair guard 3', [[8040, 8100], 1999], 2239), ('boundary control 4', [[0, 3], 10], 1),
  ('boundary control 5', [[8580, 8700], 2000], 4600), ('normal control 6', [[9068, 9123], 1800], 1848),
  ('normal control 7', [[2820, 3420], 1800], 20160), ('normal control 8', [[3240, 3953], 2150], 26492)],
 [('regression: weekend day index 1', [[1320, 1500], 60], 204),
  ('regression variant: weekend day index 2', [[7560, 8069], 1999], 19053),
  ('partial repair guard 3', [[8160, 8760], 60], 677), ('boundary control 4', [[6600, 7260], 2000], 24200),
  ('boundary control 5', [[0, 3], 10], 1), ('normal control 6', [[4740, 4980], 60], 240),
  ('normal control 7', [[7140, 7860], 1800], 24624), ('normal control 8', [[3840, 4320], 2000], 17700)],
 [('regression: weekend day index 1', [[480, 960], 1999], 16192),
  ('regression variant: weekend day index 2', [[7560, 8280], 1999], 26927),
  ('partial repair guard 3', [[8040, 8280], 90], 403), ('boundary control 4', [[1320, 1500], 60], 204),
  ('boundary control 5', [[6600, 7260], 2000], 24200), ('normal control 6', [[1320, 1920], 2000], 22600),
  ('normal control 7', [[5220, 5502], 60], 310), ('normal control 8', [[8313, 8373], 60], 67)],
 [('regression: weekend day index 1', [[7958, 8472], 1999], 19180),
  ('regression variant: weekend day index 2', [[10020, 10740], 90], 1188),
  ('partial repair guard 3', [[8160, 8880], 60], 815), ('boundary control 4', [[480, 960], 1999], 16192),
  ('boundary control 5', [[1320, 1500], 60], 204), ('normal control 6', [[5760, 6000], 2000], 9200),
  ('normal control 7', [[6660, 6720], 2150], 2365), ('normal control 8', [[4740, 5460], 2000], 24800)]]
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: weekend day index 119801980Passed
regression variant: weekend day index 22638727346Failed
partial repair guard 310171028Failed
boundary control 446004600Passed
normal control 522992299Passed
normal control 62016020160Passed
normal control 7734734Passed
normal control 81402714027Passed

SHA-256 / 32db360b8d8a34494d07a9fca7d9ff24e4e309416093f8ebdf53726213823052

3 / The verified repair

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

N = 1
observations = []
def solve(shift, base):
    s, e = shift
    total = 0
    for t in range(s, e):
        day = (t // 1440) % 7
        m = t % 1440
        pct = 0
        if 900 <= m < 1380:
            pct = 10
        if m >= 1380 or m < 420:
            pct = 15
        if day >= 5:
            pct = max(pct, 12)
        total += base * (100 + pct)
    return (total + 3000) // 6000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekend day index 1', [[900, 960], 1800], 1980),
  ('regression variant: weekend day index 2', [[7140, 7860], 1999], 27346),
  ('partial repair guard 3', [[7080, 7680], 90], 1028), ('boundary control 4', [[8580, 8700], 2000], 4600),
  ('normal control 5', [[7560, 7620], 1999], 2299), ('normal control 6', [[2820, 3420], 1800], 20160),
  ('normal control 7', [[360, 840], 90], 734), ('normal control 8', [[3621, 4018], 2000], 14027)],
 [('regression: weekend day index 1', [[7200, 7800], 2000], 22820),
  ('regression variant: weekend day index 2', [[900, 1140], 1999], 8796),
  ('partial repair guard 3', [[8040, 8100], 1999], 2239), ('boundary control 4', [[0, 3], 10], 1),
  ('boundary control 5', [[8580, 8700], 2000], 4600), ('normal control 6', [[9068, 9123], 1800], 1848),
  ('normal control 7', [[2820, 3420], 1800], 20160), ('normal control 8', [[3240, 3953], 2150], 26492)],
 [('regression: weekend day index 1', [[1320, 1500], 60], 204),
  ('regression variant: weekend day index 2', [[7560, 8069], 1999], 19053),
  ('partial repair guard 3', [[8160, 8760], 60], 677), ('boundary control 4', [[6600, 7260], 2000], 24200),
  ('boundary control 5', [[0, 3], 10], 1), ('normal control 6', [[4740, 4980], 60], 240),
  ('normal control 7', [[7140, 7860], 1800], 24624), ('normal control 8', [[3840, 4320], 2000], 17700)],
 [('regression: weekend day index 1', [[480, 960], 1999], 16192),
  ('regression variant: weekend day index 2', [[7560, 8280], 1999], 26927),
  ('partial repair guard 3', [[8040, 8280], 90], 403), ('boundary control 4', [[1320, 1500], 60], 204),
  ('boundary control 5', [[6600, 7260], 2000], 24200), ('normal control 6', [[1320, 1920], 2000], 22600),
  ('normal control 7', [[5220, 5502], 60], 310), ('normal control 8', [[8313, 8373], 60], 67)],
 [('regression: weekend day index 1', [[7958, 8472], 1999], 19180),
  ('regression variant: weekend day index 2', [[10020, 10740], 90], 1188),
  ('partial repair guard 3', [[8160, 8880], 60], 815), ('boundary control 4', [[480, 960], 1999], 16192),
  ('boundary control 5', [[1320, 1500], 60], 204), ('normal control 6', [[5760, 6000], 2000], 9200),
  ('normal control 7', [[6660, 6720], 2150], 2365), ('normal control 8', [[4740, 5460], 2000], 24800)]]
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: weekend day index 119801980Passed
regression variant: weekend day index 22734627346Passed
partial repair guard 310281028Passed
boundary control 446004600Passed
normal control 522992299Passed
normal control 62016020160Passed
normal control 7734734Passed
normal control 81402714027Passed

SHA-256 / 0261f7a97133271e307c43486966736f096e65a5beb400a795ce817c4f5bac04

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

Case digest / 666481f8970d112cf8c751a88dc820a9e4901493e1df734009133efafc592b72