FAILURE MAP
← Case archive

FA-94211 / Shift rostering labor rules / Open access

Neighbour search treats day zero as scheduled · case 01

A holiday whose only prior days are unscheduled treats an off day at index 0 as the prior shift and is denied.

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

ROOT CAUSE

The skip loop stops before examining index 0.

VERIFIED REPAIR

Skip over index 0 like any other day.

Unsuccessful approach: Stopping before the last index has the same defect at the far end.

Case contract

A day-status string (W worked, A unexcused absence, X excused absence, O not scheduled) and holiday indices. A holiday is paid if the nearest scheduled day before it and the nearest after it (skipping O days and other holidays) are both W or X; if either does not exist in the roster, it is not paid. Return [holiday, eligible] in holiday order.

Why this case matters

Last-and-first-shift holiday pay rules are frequently misapplied around days off and adjacent holidays.

1 / The failure

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

N = 1
observations = []
def solve(days, holidays):
    hs = set(holidays)
    ok = ('W', 'X')
    def near(i, step):
        j = i + step
        while 0 < j < len(days) and (days[j] == 'O' or j in hs):
            j += step
        return days[j] if 0 <= j < len(days) else None
    return [[h, near(h, -1) in ok and near(h, 1) in ok] for h in sorted(holidays)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['OWWOOOW', [3, 6, 4]], [[3, False], [4, False], [6, False]]),
  ('boundary control 4', ['OWOOW', [2]], [[2, True]]), ('boundary control 5', ['WAOWW', [2]], [[2, False]]),
  ('normal control 6', ['OAOXWXXOOW', [7]], [[7, True]]),
  ('normal control 7', ['WOWWWOXXAOO', [4, 5, 10]], [[4, True], [5, True], [10, False]]),
  ('normal control 8', ['WWXWXOWAWOWW', [8, 5]], [[5, True], [8, False]])],
 [('regression: search lower bound 1', ['WOWOOOW', [3, 1, 0]], [[0, False], [1, False], [3, True]]),
  ('partial repair guard 2', ['OOAXOOW', [4, 0, 6]], [[0, False], [4, False], [6, False]]),
  ('boundary control 3', ['WWOWA', [2]], [[2, True]]),
  ('boundary control 4', ['WOOOW', [1, 2]], [[1, True], [2, True]]),
  ('normal control 5', ['OWXWOXWWOXWA', [1]], [[1, False]]),
  ('normal control 6', ['OWAWOWOWOWO', [0, 4, 8]], [[0, False], [4, True], [8, True]]),
  ('normal control 7', ['XXOXXOO', [6]], [[6, False]]),
  ('normal control 8', ['OWWOWWOWO', [5, 8, 6]], [[5, True], [6, True], [8, False]])],
 [('regression: search lower bound 1', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('regression variant: search lower bound 2', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('partial repair guard 3', ['WOAXAXXWW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WXOWX', [2]], [[2, True]]), ('boundary control 5', ['WOOWW', [2]], [[2, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['WOWWOWO', [6, 0, 4]], [[0, False], [4, True], [6, False]]),
  ('normal control 8', ['XOOAWWAWWAW', [10, 2]], [[2, False], [10, False]])],
 [('regression: search lower bound 1', ['WOWOWOX', [0, 1, 4]], [[0, False], [1, False], [4, True]]),
  ('partial repair guard 2', ['XOOXOW', [1, 4, 5]], [[1, True], [4, False], [5, False]]),
  ('boundary control 3', ['OOWWW', [0]], [[0, False]]), ('boundary control 4', ['OWOOW', [2]], [[2, True]]),
  ('normal control 5', ['WWOWOWWOW', [7]], [[7, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['AWWWWW', [5, 3]], [[3, True], [5, False]]),
  ('normal control 8', ['XOWOAWW', [3, 1, 6]], [[1, True], [3, False], [6, False]])],
 [('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['AOWOXWOOW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WAOWW', [2]], [[2, False]]), ('boundary control 5', ['WWOWA', [2]], [[2, True]]),
  ('normal control 6', ['XWWWWXWWWWW', [10, 4]], [[4, True], [10, False]]),
  ('normal control 7', ['OAWXWXXWOA', [8]], [[8, False]]),
  ('normal control 8', ['WWOWWOOXX', [4, 2, 5]], [[2, True], [4, True], [5, 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: search lower bound 1[[0, False], [1, True], [7, False]][[0, False], [1, False], [7, False]]Failed
regression variant: search lower bound 2[[0, False], [2, True], [3, True]][[0, False], [2, False], [3, False]]Failed
partial repair guard 3[[3, False], [4, False], [6, False]][[3, False], [4, False], [6, False]]Passed
boundary control 4[[2, True]][[2, True]]Passed
boundary control 5[[2, False]][[2, False]]Passed
normal control 6[[7, True]][[7, True]]Passed
normal control 7[[4, True], [5, True], [10, False]][[4, True], [5, True], [10, False]]Passed
normal control 8[[5, True], [8, False]][[5, True], [8, False]]Passed

SHA-256 / a8bbe279c883356c6357bb3039923c646a482bbb302b7b59ca64ba56a671d4cf

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(days, holidays):
    hs = set(holidays)
    ok = ('W', 'X')
    def near(i, step):
        j = i + step
        while 0 <= j < len(days) - 1 and (days[j] == 'O' or j in hs):
            j += step
        return days[j] if 0 <= j < len(days) else None
    return [[h, near(h, -1) in ok and near(h, 1) in ok] for h in sorted(holidays)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['OWWOOOW', [3, 6, 4]], [[3, False], [4, False], [6, False]]),
  ('boundary control 4', ['OWOOW', [2]], [[2, True]]), ('boundary control 5', ['WAOWW', [2]], [[2, False]]),
  ('normal control 6', ['OAOXWXXOOW', [7]], [[7, True]]),
  ('normal control 7', ['WOWWWOXXAOO', [4, 5, 10]], [[4, True], [5, True], [10, False]]),
  ('normal control 8', ['WWXWXOWAWOWW', [8, 5]], [[5, True], [8, False]])],
 [('regression: search lower bound 1', ['WOWOOOW', [3, 1, 0]], [[0, False], [1, False], [3, True]]),
  ('partial repair guard 2', ['OOAXOOW', [4, 0, 6]], [[0, False], [4, False], [6, False]]),
  ('boundary control 3', ['WWOWA', [2]], [[2, True]]),
  ('boundary control 4', ['WOOOW', [1, 2]], [[1, True], [2, True]]),
  ('normal control 5', ['OWXWOXWWOXWA', [1]], [[1, False]]),
  ('normal control 6', ['OWAWOWOWOWO', [0, 4, 8]], [[0, False], [4, True], [8, True]]),
  ('normal control 7', ['XXOXXOO', [6]], [[6, False]]),
  ('normal control 8', ['OWWOWWOWO', [5, 8, 6]], [[5, True], [6, True], [8, False]])],
 [('regression: search lower bound 1', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('regression variant: search lower bound 2', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('partial repair guard 3', ['WOAXAXXWW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WXOWX', [2]], [[2, True]]), ('boundary control 5', ['WOOWW', [2]], [[2, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['WOWWOWO', [6, 0, 4]], [[0, False], [4, True], [6, False]]),
  ('normal control 8', ['XOOAWWAWWAW', [10, 2]], [[2, False], [10, False]])],
 [('regression: search lower bound 1', ['WOWOWOX', [0, 1, 4]], [[0, False], [1, False], [4, True]]),
  ('partial repair guard 2', ['XOOXOW', [1, 4, 5]], [[1, True], [4, False], [5, False]]),
  ('boundary control 3', ['OOWWW', [0]], [[0, False]]), ('boundary control 4', ['OWOOW', [2]], [[2, True]]),
  ('normal control 5', ['WWOWOWWOW', [7]], [[7, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['AWWWWW', [5, 3]], [[3, True], [5, False]]),
  ('normal control 8', ['XOWOAWW', [3, 1, 6]], [[1, True], [3, False], [6, False]])],
 [('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['AOWOXWOOW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WAOWW', [2]], [[2, False]]), ('boundary control 5', ['WWOWA', [2]], [[2, True]]),
  ('normal control 6', ['XWWWWXWWWWW', [10, 4]], [[4, True], [10, False]]),
  ('normal control 7', ['OAWXWXXWOA', [8]], [[8, False]]),
  ('normal control 8', ['WWOWWOOXX', [4, 2, 5]], [[2, True], [4, True], [5, 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: search lower bound 1[[0, False], [1, False], [7, False]][[0, False], [1, False], [7, False]]Passed
regression variant: search lower bound 2[[0, False], [2, False], [3, False]][[0, False], [2, False], [3, False]]Passed
partial repair guard 3[[3, True], [4, True], [6, False]][[3, False], [4, False], [6, False]]Failed
boundary control 4[[2, True]][[2, True]]Passed
boundary control 5[[2, False]][[2, False]]Passed
normal control 6[[7, True]][[7, True]]Passed
normal control 7[[4, True], [5, True], [10, False]][[4, True], [5, True], [10, False]]Passed
normal control 8[[5, True], [8, False]][[5, True], [8, False]]Passed

SHA-256 / 14677e171d7cf3702eae0e2c039adc1f92dcb1cacffe2eb3435a271ab910ab1f

3 / The verified repair

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

N = 1
observations = []
def solve(days, holidays):
    hs = set(holidays)
    ok = ('W', 'X')
    def near(i, step):
        j = i + step
        while 0 <= j < len(days) and (days[j] == 'O' or j in hs):
            j += step
        return days[j] if 0 <= j < len(days) else None
    return [[h, near(h, -1) in ok and near(h, 1) in ok] for h in sorted(holidays)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['OWWOOOW', [3, 6, 4]], [[3, False], [4, False], [6, False]]),
  ('boundary control 4', ['OWOOW', [2]], [[2, True]]), ('boundary control 5', ['WAOWW', [2]], [[2, False]]),
  ('normal control 6', ['OAOXWXXOOW', [7]], [[7, True]]),
  ('normal control 7', ['WOWWWOXXAOO', [4, 5, 10]], [[4, True], [5, True], [10, False]]),
  ('normal control 8', ['WWXWXOWAWOWW', [8, 5]], [[5, True], [8, False]])],
 [('regression: search lower bound 1', ['WOWOOOW', [3, 1, 0]], [[0, False], [1, False], [3, True]]),
  ('partial repair guard 2', ['OOAXOOW', [4, 0, 6]], [[0, False], [4, False], [6, False]]),
  ('boundary control 3', ['WWOWA', [2]], [[2, True]]),
  ('boundary control 4', ['WOOOW', [1, 2]], [[1, True], [2, True]]),
  ('normal control 5', ['OWXWOXWWOXWA', [1]], [[1, False]]),
  ('normal control 6', ['OWAWOWOWOWO', [0, 4, 8]], [[0, False], [4, True], [8, True]]),
  ('normal control 7', ['XXOXXOO', [6]], [[6, False]]),
  ('normal control 8', ['OWWOWWOWO', [5, 8, 6]], [[5, True], [6, True], [8, False]])],
 [('regression: search lower bound 1', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('regression variant: search lower bound 2', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('partial repair guard 3', ['WOAXAXXWW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WXOWX', [2]], [[2, True]]), ('boundary control 5', ['WOOWW', [2]], [[2, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['WOWWOWO', [6, 0, 4]], [[0, False], [4, True], [6, False]]),
  ('normal control 8', ['XOOAWWAWWAW', [10, 2]], [[2, False], [10, False]])],
 [('regression: search lower bound 1', ['WOWOWOX', [0, 1, 4]], [[0, False], [1, False], [4, True]]),
  ('partial repair guard 2', ['XOOXOW', [1, 4, 5]], [[1, True], [4, False], [5, False]]),
  ('boundary control 3', ['OOWWW', [0]], [[0, False]]), ('boundary control 4', ['OWOOW', [2]], [[2, True]]),
  ('normal control 5', ['WWOWOWWOW', [7]], [[7, True]]),
  ('normal control 6', ['WXWWAOOW', [5]], [[5, False]]),
  ('normal control 7', ['AWWWWW', [5, 3]], [[3, True], [5, False]]),
  ('normal control 8', ['XOWOAWW', [3, 1, 6]], [[1, True], [3, False], [6, False]])],
 [('regression: search lower bound 1', ['WOWXXOAW', [1, 7, 0]], [[0, False], [1, False], [7, False]]),
  ('regression variant: search lower bound 2', ['WOOOWOW', [3, 2, 0]], [[0, False], [2, False], [3, False]]),
  ('partial repair guard 3', ['AOWOXWOOW', [7, 8]], [[7, False], [8, False]]),
  ('boundary control 4', ['WAOWW', [2]], [[2, False]]), ('boundary control 5', ['WWOWA', [2]], [[2, True]]),
  ('normal control 6', ['XWWWWXWWWWW', [10, 4]], [[4, True], [10, False]]),
  ('normal control 7', ['OAWXWXXWOA', [8]], [[8, False]]),
  ('normal control 8', ['WWOWWOOXX', [4, 2, 5]], [[2, True], [4, True], [5, 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: search lower bound 1[[0, False], [1, False], [7, False]][[0, False], [1, False], [7, False]]Passed
regression variant: search lower bound 2[[0, False], [2, False], [3, False]][[0, False], [2, False], [3, False]]Passed
partial repair guard 3[[3, False], [4, False], [6, False]][[3, False], [4, False], [6, False]]Passed
boundary control 4[[2, True]][[2, True]]Passed
boundary control 5[[2, False]][[2, False]]Passed
normal control 6[[7, True]][[7, True]]Passed
normal control 7[[4, True], [5, True], [10, False]][[4, True], [5, True], [10, False]]Passed
normal control 8[[5, True], [8, False]][[5, True], [8, False]]Passed

SHA-256 / 0ac7b644e8e36c29ebe3453e47534e534d4bd7da81cc62c9c979f40bcfe87ea1

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

Case digest / 442f13dbeb6746019cd458404c6096a5b0c5b644c1ce0032549e0258ee3c65ee