FAILURE MAP
← Case archive

FA-94121 / Shift rostering labor rules / Open access

Swap rejected for exactly the minimum rest · case 01

A swap leaving exactly ten hours rest is refused.

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

ROOT CAUSE

The rest comparison is inclusive.

VERIFIED REPAIR

Reject only gaps strictly below the minimum rest.

Unsuccessful approach: Measuring start to start ignores the length of the earlier shift.

Case contract

roster maps worker to shifts [id, start, end, skill]; req = [a, b, a_gives, b_gives or None]. After the swap a holds its shifts minus a_gives plus b's shift, b holds its shifts minus b_gives plus a's shift. Checks in order: receiver qualified for each received shift (a then b), then for a then b sorted by start: overlap, then rest below the minimum, then total minutes above cap. Return the first failure [reason, worker] or ["ok", None].

Why this case matters

Self-service shift swaps must be revalidated against labor rules for both parties after the exchange.

1 / The failure

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

N = 1
observations = []
def solve(roster, quals, req, rest, cap):
    a, b, ga, gb = req
    sa = [t for t in roster[a] if t[0] == ga][0]
    sb = [t for t in roster[b] if t[0] == gb]
    sb = sb[0] if sb else None
    new = {a: [t for t in roster[a] if t[0] != ga] + ([sb] if sb else []),
           b: [t for t in roster[b] if t[0] != gb] + [sa]}
    got = {a: sb, b: sa}
    for w in (a, b):
        if got[w] and got[w][3] not in quals[w]:
            return ['qual', w]
    for w in (a, b):
        seq = sorted(new[w], key=lambda t: t[1])
        for p, q in zip(seq, seq[1:]):
            if q[1] < p[2]:
                return ['overlap', w]
            if q[1] - p[2] <= rest:
                return ['rest', w]
    for w in (a, b):
        if sum(t[2] - t[1] for t in new[w]) > cap:
            return ['cap', w]
    return ['ok', None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: rest boundary 1',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 60, 300, 'rn'], ['u', 2200, 2680, 'rn'], ['t', 1000, 1600, 'rn']],
     'b': [['w', 899, 1139, 'icu'], ['v', 60, 300, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 960],
   ['rest', 'b']),
  ('partial repair guard 3',
   [{'a': [['u', 2439, 3039, 'rn'], ['t', 839, 1439, 'rn'], ['s', 0, 240, 'rn']],
     'b': [['v', 0, 480, 'rn'], ['w', 1480, 2080, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('normal control 4',
   [{'a': [['s', 60, 660, 'icu'], ['u', 2200, 2440, 'rn'], ['t', 1660, 1900, 'rn']],
     'b': [['v', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 960],
   ['overlap', 'a']),
  ('normal control 5',
   [{'a': [['t', 1200, 1440, 'icu'], ['s', 0, 600, 'rn']],
     'b': [['v', 780, 1260, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['rest', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 660, 'icu']],
     'b': [['v', 1779, 2259, 'rn'], ['u', 940, 1180, 'rn'], ['t', 0, 240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['u', 1379, 1619, 'rn'], ['t', 540, 780, 'rn'], ['s', 0, 240, 'rn']], 'b': [['v', 0, 480, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', 'v'], 600, 1440],
   ['qual', 'a']),
  ('normal control 8',
   [{'a': [['t', 899, 1379, 'rn'], ['s', 60, 300, 'rn'], ['u', 2379, 2619, 'icu']],
     'b': [['v', 0, 240, 'rn'], ['w', 840, 1080, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 60, 540, 'icu'], ['u', 2080, 2680, 'rn']],
     'b': [['w', 1200, 1440, 'rn'], ['v', 0, 600, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['u', 2559, 3159, 'rn'], ['t', 1259, 1859, 'rn'], ['s', 60, 660, 'icu']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 720, 'rn'], ['t', 1400, 1880, 'rn']], 'b': [['u', 3000, 3240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 720],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']],
     'b': [['v', 2379, 2859, 'rn'], ['u', 1300, 1780, 'rn'], ['t', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu'], ['t', 899, 1379, 'rn'], ['u', 2079, 2559, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a']),
  ('normal control 7',
   [{'a': [['s', 60, 300, 'rn']], 'b': [['t', 60, 540, 'icu']]}, {'a': ['rn'], 'b': ['rn', 'icu']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['u', 1840, 2320, 'rn'], ['t', 900, 1140, 'icu'], ['s', 60, 300, 'icu']],
     'b': [['x', 1840, 2440, 'icu'], ['w', 540, 1140, 'icu'], ['v', 0, 240, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 0, 240, 'icu']],
     'b': [['u', 0, 600, 'rn'], ['v', 1200, 1800, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 240, 'icu'], ['u', 1920, 2520, 'rn'], ['t', 840, 1320, 'rn']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 'u', None], 600, 960],
   ['cap', 'b']),
  ('partial repair guard 3',
   [{'a': [['t', 1480, 2080, 'rn'], ['s', 0, 480, 'rn']],
     'b': [['u', 0, 240, 'icu'], ['v', 839, 1319, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 480, 'icu']], 'b': [['u', 2000, 2480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['u', 1840, 2080, 'icu'], ['s', 0, 600, 'rn'], ['t', 900, 1140, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'icu'], ['x', 1920, 2160, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 1200],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['t', 0, 480, 'icu'], ['u', 1080, 1560, 'rn'], ['v', 2260, 2500, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['s', 60, 660, 'rn']],
     'b': [['u', 1600, 2200, 'rn'], ['t', 0, 600, 'icu'], ['v', 3200, 3680, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['u', 1259, 1499, 'icu'], ['t', 60, 660, 'rn'], ['v', 1799, 2039, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['rest', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn'], ['u', 2420, 3020, 'rn']],
     'b': [['w', 1139, 1619, 'rn'], ['v', 60, 540, 'rn'], ['x', 2219, 2459, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 600, 'icu'], ['u', 2100, 2580, 'icu'], ['t', 900, 1500, 'rn']],
     'b': [['v', 60, 300, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn'], ['u', 2319, 2559, 'icu'], ['t', 1480, 1720, 'icu']],
     'b': [['w', 940, 1540, 'icu'], ['v', 0, 240, 'rn'], ['x', 2140, 2620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['t', 1200, 1680, 'rn'], ['s', 0, 700, 'icu']], 'b': [['u', 3000, 3700, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 1180],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['u', 2100, 2700, 'icu'], ['s', 60, 660, 'icu'], ['t', 1260, 1500, 'rn']],
     'b': [['x', 1979, 2219, 'rn'], ['v', 0, 480, 'rn'], ['w', 1079, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'x'], 600, 960],
   ['rest', 'a']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu']], 'b': [['t', 0, 480, 'rn'], ['u', 1180, 1660, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 't'], 600, 1440],
   ['ok', None]),
  ('normal control 7',
   [{'a': [['s', 0, 240, 'rn'], ['t', 540, 1140, 'rn']],
     'b': [['v', 1180, 1660, 'icu'], ['w', 2259, 2859, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 60, 300, 'rn']],
     'b': [['v', 2080, 2680, 'rn'], ['u', 1540, 1780, 'rn'], ['t', 60, 540, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['u', 1440, 1920, 'rn'], ['t', 600, 840, 'icu'], ['s', 60, 300, 'rn']],
     'b': [['v', 60, 660, 'rn'], ['w', 1660, 2260, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'a']),
  ('partial repair guard 2',
   [{'a': [['s', 60, 300, 'rn'], ['t', 899, 1379, 'rn']],
     'b': [['u', 60, 660, 'rn'], ['v', 1360, 1960, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 't', None], 600, 1200],
   ['rest', 'b']),
  ('boundary control 3',
   [{'a': [['s', 0, 600, 'rn'], ['t', 1200, 1680, 'rn']], 'b': [['u', 3000, 3480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['t', 1180, 1420, 'rn'], ['s', 0, 480, 'icu'], ['u', 2019, 2619, 'icu']],
     'b': [['x', 2080, 2560, 'icu'], ['v', 0, 480, 'rn'], ['w', 1180, 1780, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'w'], 600, 960],
   ['rest', 'a']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2080, 2560, 'rn'], ['t', 60, 540, 'rn'], ['u', 1240, 1480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', 't'], 600, 1200],
   ['qual', 'a']),
  ('normal control 7',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b'])]]
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: rest boundary 1['rest', 'b']['ok', None]Failed
regression variant: rest boundary 2['rest', 'a']['rest', 'b']Failed
partial repair guard 3['rest', 'a']['rest', 'a']Passed
normal control 4['overlap', 'a']['overlap', 'a']Passed
normal control 5['rest', 'b']['rest', 'b']Passed
normal control 6['qual', 'b']['qual', 'b']Passed
normal control 7['qual', 'a']['qual', 'a']Passed
normal control 8['rest', 'a']['rest', 'a']Passed

SHA-256 / ca483222b71b5097e7235710cbc04dde7cd3293fe7211d7589996d2ab2fa0ece

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(roster, quals, req, rest, cap):
    a, b, ga, gb = req
    sa = [t for t in roster[a] if t[0] == ga][0]
    sb = [t for t in roster[b] if t[0] == gb]
    sb = sb[0] if sb else None
    new = {a: [t for t in roster[a] if t[0] != ga] + ([sb] if sb else []),
           b: [t for t in roster[b] if t[0] != gb] + [sa]}
    got = {a: sb, b: sa}
    for w in (a, b):
        if got[w] and got[w][3] not in quals[w]:
            return ['qual', w]
    for w in (a, b):
        seq = sorted(new[w], key=lambda t: t[1])
        for p, q in zip(seq, seq[1:]):
            if q[1] < p[2]:
                return ['overlap', w]
            if q[1] - p[1] < rest:
                return ['rest', w]
    for w in (a, b):
        if sum(t[2] - t[1] for t in new[w]) > cap:
            return ['cap', w]
    return ['ok', None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: rest boundary 1',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 60, 300, 'rn'], ['u', 2200, 2680, 'rn'], ['t', 1000, 1600, 'rn']],
     'b': [['w', 899, 1139, 'icu'], ['v', 60, 300, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 960],
   ['rest', 'b']),
  ('partial repair guard 3',
   [{'a': [['u', 2439, 3039, 'rn'], ['t', 839, 1439, 'rn'], ['s', 0, 240, 'rn']],
     'b': [['v', 0, 480, 'rn'], ['w', 1480, 2080, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('normal control 4',
   [{'a': [['s', 60, 660, 'icu'], ['u', 2200, 2440, 'rn'], ['t', 1660, 1900, 'rn']],
     'b': [['v', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 960],
   ['overlap', 'a']),
  ('normal control 5',
   [{'a': [['t', 1200, 1440, 'icu'], ['s', 0, 600, 'rn']],
     'b': [['v', 780, 1260, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['rest', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 660, 'icu']],
     'b': [['v', 1779, 2259, 'rn'], ['u', 940, 1180, 'rn'], ['t', 0, 240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['u', 1379, 1619, 'rn'], ['t', 540, 780, 'rn'], ['s', 0, 240, 'rn']], 'b': [['v', 0, 480, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', 'v'], 600, 1440],
   ['qual', 'a']),
  ('normal control 8',
   [{'a': [['t', 899, 1379, 'rn'], ['s', 60, 300, 'rn'], ['u', 2379, 2619, 'icu']],
     'b': [['v', 0, 240, 'rn'], ['w', 840, 1080, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 60, 540, 'icu'], ['u', 2080, 2680, 'rn']],
     'b': [['w', 1200, 1440, 'rn'], ['v', 0, 600, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['u', 2559, 3159, 'rn'], ['t', 1259, 1859, 'rn'], ['s', 60, 660, 'icu']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 720, 'rn'], ['t', 1400, 1880, 'rn']], 'b': [['u', 3000, 3240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 720],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']],
     'b': [['v', 2379, 2859, 'rn'], ['u', 1300, 1780, 'rn'], ['t', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu'], ['t', 899, 1379, 'rn'], ['u', 2079, 2559, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a']),
  ('normal control 7',
   [{'a': [['s', 60, 300, 'rn']], 'b': [['t', 60, 540, 'icu']]}, {'a': ['rn'], 'b': ['rn', 'icu']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['u', 1840, 2320, 'rn'], ['t', 900, 1140, 'icu'], ['s', 60, 300, 'icu']],
     'b': [['x', 1840, 2440, 'icu'], ['w', 540, 1140, 'icu'], ['v', 0, 240, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 0, 240, 'icu']],
     'b': [['u', 0, 600, 'rn'], ['v', 1200, 1800, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 240, 'icu'], ['u', 1920, 2520, 'rn'], ['t', 840, 1320, 'rn']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 'u', None], 600, 960],
   ['cap', 'b']),
  ('partial repair guard 3',
   [{'a': [['t', 1480, 2080, 'rn'], ['s', 0, 480, 'rn']],
     'b': [['u', 0, 240, 'icu'], ['v', 839, 1319, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 480, 'icu']], 'b': [['u', 2000, 2480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['u', 1840, 2080, 'icu'], ['s', 0, 600, 'rn'], ['t', 900, 1140, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'icu'], ['x', 1920, 2160, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 1200],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['t', 0, 480, 'icu'], ['u', 1080, 1560, 'rn'], ['v', 2260, 2500, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['s', 60, 660, 'rn']],
     'b': [['u', 1600, 2200, 'rn'], ['t', 0, 600, 'icu'], ['v', 3200, 3680, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['u', 1259, 1499, 'icu'], ['t', 60, 660, 'rn'], ['v', 1799, 2039, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['rest', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn'], ['u', 2420, 3020, 'rn']],
     'b': [['w', 1139, 1619, 'rn'], ['v', 60, 540, 'rn'], ['x', 2219, 2459, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 600, 'icu'], ['u', 2100, 2580, 'icu'], ['t', 900, 1500, 'rn']],
     'b': [['v', 60, 300, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn'], ['u', 2319, 2559, 'icu'], ['t', 1480, 1720, 'icu']],
     'b': [['w', 940, 1540, 'icu'], ['v', 0, 240, 'rn'], ['x', 2140, 2620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['t', 1200, 1680, 'rn'], ['s', 0, 700, 'icu']], 'b': [['u', 3000, 3700, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 1180],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['u', 2100, 2700, 'icu'], ['s', 60, 660, 'icu'], ['t', 1260, 1500, 'rn']],
     'b': [['x', 1979, 2219, 'rn'], ['v', 0, 480, 'rn'], ['w', 1079, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'x'], 600, 960],
   ['rest', 'a']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu']], 'b': [['t', 0, 480, 'rn'], ['u', 1180, 1660, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 't'], 600, 1440],
   ['ok', None]),
  ('normal control 7',
   [{'a': [['s', 0, 240, 'rn'], ['t', 540, 1140, 'rn']],
     'b': [['v', 1180, 1660, 'icu'], ['w', 2259, 2859, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 60, 300, 'rn']],
     'b': [['v', 2080, 2680, 'rn'], ['u', 1540, 1780, 'rn'], ['t', 60, 540, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['u', 1440, 1920, 'rn'], ['t', 600, 840, 'icu'], ['s', 60, 300, 'rn']],
     'b': [['v', 60, 660, 'rn'], ['w', 1660, 2260, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'a']),
  ('partial repair guard 2',
   [{'a': [['s', 60, 300, 'rn'], ['t', 899, 1379, 'rn']],
     'b': [['u', 60, 660, 'rn'], ['v', 1360, 1960, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 't', None], 600, 1200],
   ['rest', 'b']),
  ('boundary control 3',
   [{'a': [['s', 0, 600, 'rn'], ['t', 1200, 1680, 'rn']], 'b': [['u', 3000, 3480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['t', 1180, 1420, 'rn'], ['s', 0, 480, 'icu'], ['u', 2019, 2619, 'icu']],
     'b': [['x', 2080, 2560, 'icu'], ['v', 0, 480, 'rn'], ['w', 1180, 1780, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'w'], 600, 960],
   ['rest', 'a']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2080, 2560, 'rn'], ['t', 60, 540, 'rn'], ['u', 1240, 1480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', 't'], 600, 1200],
   ['qual', 'a']),
  ('normal control 7',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b'])]]
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: rest boundary 1['ok', None]['ok', None]Passed
regression variant: rest boundary 2['cap', 'a']['rest', 'b']Failed
partial repair guard 3['cap', 'b']['rest', 'a']Failed
normal control 4['overlap', 'a']['overlap', 'a']Passed
normal control 5['cap', 'b']['rest', 'b']Failed
normal control 6['qual', 'b']['qual', 'b']Passed
normal control 7['qual', 'a']['qual', 'a']Passed
normal control 8['ok', None]['rest', 'a']Failed

SHA-256 / 1514e2c565dfe64afa1793195465c7758019bb37ae864efbaf07a486290f6df2

3 / The verified repair

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

N = 1
observations = []
def solve(roster, quals, req, rest, cap):
    a, b, ga, gb = req
    sa = [t for t in roster[a] if t[0] == ga][0]
    sb = [t for t in roster[b] if t[0] == gb]
    sb = sb[0] if sb else None
    new = {a: [t for t in roster[a] if t[0] != ga] + ([sb] if sb else []),
           b: [t for t in roster[b] if t[0] != gb] + [sa]}
    got = {a: sb, b: sa}
    for w in (a, b):
        if got[w] and got[w][3] not in quals[w]:
            return ['qual', w]
    for w in (a, b):
        seq = sorted(new[w], key=lambda t: t[1])
        for p, q in zip(seq, seq[1:]):
            if q[1] < p[2]:
                return ['overlap', w]
            if q[1] - p[2] < rest:
                return ['rest', w]
    for w in (a, b):
        if sum(t[2] - t[1] for t in new[w]) > cap:
            return ['cap', w]
    return ['ok', None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: rest boundary 1',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 60, 300, 'rn'], ['u', 2200, 2680, 'rn'], ['t', 1000, 1600, 'rn']],
     'b': [['w', 899, 1139, 'icu'], ['v', 60, 300, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 960],
   ['rest', 'b']),
  ('partial repair guard 3',
   [{'a': [['u', 2439, 3039, 'rn'], ['t', 839, 1439, 'rn'], ['s', 0, 240, 'rn']],
     'b': [['v', 0, 480, 'rn'], ['w', 1480, 2080, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('normal control 4',
   [{'a': [['s', 60, 660, 'icu'], ['u', 2200, 2440, 'rn'], ['t', 1660, 1900, 'rn']],
     'b': [['v', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 960],
   ['overlap', 'a']),
  ('normal control 5',
   [{'a': [['t', 1200, 1440, 'icu'], ['s', 0, 600, 'rn']],
     'b': [['v', 780, 1260, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['rest', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 660, 'icu']],
     'b': [['v', 1779, 2259, 'rn'], ['u', 940, 1180, 'rn'], ['t', 0, 240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['u', 1379, 1619, 'rn'], ['t', 540, 780, 'rn'], ['s', 0, 240, 'rn']], 'b': [['v', 0, 480, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 'u', 'v'], 600, 1440],
   ['qual', 'a']),
  ('normal control 8',
   [{'a': [['t', 899, 1379, 'rn'], ['s', 60, 300, 'rn'], ['u', 2379, 2619, 'icu']],
     'b': [['v', 0, 240, 'rn'], ['w', 840, 1080, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 60, 540, 'icu'], ['u', 2080, 2680, 'rn']],
     'b': [['w', 1200, 1440, 'rn'], ['v', 0, 600, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['u', 2559, 3159, 'rn'], ['t', 1259, 1859, 'rn'], ['s', 60, 660, 'icu']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 720, 'rn'], ['t', 1400, 1880, 'rn']], 'b': [['u', 3000, 3240, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 720],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']],
     'b': [['v', 2379, 2859, 'rn'], ['u', 1300, 1780, 'rn'], ['t', 0, 600, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu'], ['t', 899, 1379, 'rn'], ['u', 2079, 2559, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', None], 600, 1200],
   ['rest', 'a']),
  ('normal control 7',
   [{'a': [['s', 60, 300, 'rn']], 'b': [['t', 60, 540, 'icu']]}, {'a': ['rn'], 'b': ['rn', 'icu']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['u', 1840, 2320, 'rn'], ['t', 900, 1140, 'icu'], ['s', 60, 300, 'icu']],
     'b': [['x', 1840, 2440, 'icu'], ['w', 540, 1140, 'icu'], ['v', 0, 240, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1480, 'rn'], ['s', 0, 240, 'icu']],
     'b': [['u', 0, 600, 'rn'], ['v', 1200, 1800, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 1200],
   ['overlap', 'b']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 240, 'icu'], ['u', 1920, 2520, 'rn'], ['t', 840, 1320, 'rn']],
     'b': [['v', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 'u', None], 600, 960],
   ['cap', 'b']),
  ('partial repair guard 3',
   [{'a': [['t', 1480, 2080, 'rn'], ['s', 0, 480, 'rn']],
     'b': [['u', 0, 240, 'icu'], ['v', 839, 1319, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['s', 0, 480, 'icu']], 'b': [['u', 2000, 2480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['u', 1840, 2080, 'icu'], ['s', 0, 600, 'rn'], ['t', 900, 1140, 'rn']],
     'b': [['w', 840, 1320, 'rn'], ['v', 60, 540, 'icu'], ['x', 1920, 2160, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', 'v'], 600, 1200],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['t', 0, 480, 'icu'], ['u', 1080, 1560, 'rn'], ['v', 2260, 2500, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['qual', 'b']),
  ('normal control 7',
   [{'a': [['s', 60, 660, 'rn']],
     'b': [['u', 1600, 2200, 'rn'], ['t', 0, 600, 'icu'], ['v', 3200, 3680, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['u', 1259, 1499, 'icu'], ['t', 60, 660, 'rn'], ['v', 1799, 2039, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['rest', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn'], ['u', 2420, 3020, 'rn']],
     'b': [['w', 1139, 1619, 'rn'], ['v', 60, 540, 'rn'], ['x', 2219, 2459, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('regression variant: rest boundary 2',
   [{'a': [['s', 0, 600, 'icu'], ['u', 2100, 2580, 'icu'], ['t', 900, 1500, 'rn']],
     'b': [['v', 60, 300, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn'], ['u', 2319, 2559, 'icu'], ['t', 1480, 1720, 'icu']],
     'b': [['w', 940, 1540, 'icu'], ['v', 0, 240, 'rn'], ['x', 2140, 2620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['rest', 'a']),
  ('boundary control 4',
   [{'a': [['t', 1200, 1680, 'rn'], ['s', 0, 700, 'icu']], 'b': [['u', 3000, 3700, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 1180],
   ['ok', None]),
  ('normal control 5',
   [{'a': [['u', 2100, 2700, 'icu'], ['s', 60, 660, 'icu'], ['t', 1260, 1500, 'rn']],
     'b': [['x', 1979, 2219, 'rn'], ['v', 0, 480, 'rn'], ['w', 1079, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'x'], 600, 960],
   ['rest', 'a']),
  ('normal control 6',
   [{'a': [['s', 60, 300, 'icu']], 'b': [['t', 0, 480, 'rn'], ['u', 1180, 1660, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 't'], 600, 1440],
   ['ok', None]),
  ('normal control 7',
   [{'a': [['s', 0, 240, 'rn'], ['t', 540, 1140, 'rn']],
     'b': [['v', 1180, 1660, 'icu'], ['w', 2259, 2859, 'rn'], ['u', 0, 480, 'rn']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 60, 300, 'rn']],
     'b': [['v', 2080, 2680, 'rn'], ['u', 1540, 1780, 'rn'], ['t', 60, 540, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b'])],
 [('regression: rest boundary 1',
   [{'a': [['u', 1440, 1920, 'rn'], ['t', 600, 840, 'icu'], ['s', 60, 300, 'rn']],
     'b': [['v', 60, 660, 'rn'], ['w', 1660, 2260, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'w'], 600, 960],
   ['overlap', 'a']),
  ('partial repair guard 2',
   [{'a': [['s', 60, 300, 'rn'], ['t', 899, 1379, 'rn']],
     'b': [['u', 60, 660, 'rn'], ['v', 1360, 1960, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 't', None], 600, 1200],
   ['rest', 'b']),
  ('boundary control 3',
   [{'a': [['s', 0, 600, 'rn'], ['t', 1200, 1680, 'rn']], 'b': [['u', 3000, 3480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['t', 1180, 1420, 'rn'], ['s', 0, 480, 'icu'], ['u', 2019, 2619, 'icu']],
     'b': [['x', 2080, 2560, 'icu'], ['v', 0, 480, 'rn'], ['w', 1180, 1780, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'w'], 600, 960],
   ['rest', 'a']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2080, 2560, 'rn'], ['t', 60, 540, 'rn'], ['u', 1240, 1480, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', None], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', 't'], 600, 1200],
   ['qual', 'a']),
  ('normal control 7',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['t', 0, 600, 'icu']]}, {'a': ['rn'], 'b': ['icu', 'rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']], 'b': [['t', 0, 480, 'rn']]}, {'a': ['rn', 'icu'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b'])]]
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: rest boundary 1['ok', None]['ok', None]Passed
regression variant: rest boundary 2['rest', 'b']['rest', 'b']Passed
partial repair guard 3['rest', 'a']['rest', 'a']Passed
normal control 4['overlap', 'a']['overlap', 'a']Passed
normal control 5['rest', 'b']['rest', 'b']Passed
normal control 6['qual', 'b']['qual', 'b']Passed
normal control 7['qual', 'a']['qual', 'a']Passed
normal control 8['rest', 'a']['rest', 'a']Passed

SHA-256 / 0eeca49cca37a57ff977e6891298a4244c8cffe0bbc86ecedaabd4d29cef268e

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

Case digest / 5e9214769481240bef4bdf151263d2dae978313eafd6e752dfe643312953b9a8