FAILURE MAP
← Case archive

FA-94126 / Shift rostering labor rules / Open access

Hours cap rejects rosters exactly at the cap · case 01

A swap bringing a worker to exactly the cap is refused.

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

ROOT CAUSE

The hours cap comparison is inclusive.

VERIFIED REPAIR

Reject only totals above the cap, measured after the swap.

Unsuccessful approach: Measuring pre-swap totals ignores the hours actually received.

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: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('boundary control 3',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'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']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu'], ['t', 1199, 1679, 'rn'], ['u', 1979, 2579, 'icu']],
     'b': [['v', 60, 540, 'icu'], ['x', 2440, 2680, 'rn'], ['w', 1240, 1840, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'x'], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'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 7',
   [{'a': [['s', 60, 540, 'rn']], 'b': [['u', 1260, 1740, 'icu'], ['t', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['t', 1540, 2020, 'rn'], ['s', 60, 540, 'icu']],
     'b': [['w', 2279, 2759, 'rn'], ['u', 0, 600, 'rn'], ['v', 1199, 1679, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1240, 1720, 'rn']], 'b': [['u', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['s', 60, 300, 'icu']],
     'b': [['t', 60, 660, 'rn'], ['u', 1660, 2140, 'icu'], ['v', 3140, 3620, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']], 'b': [['t', 60, 300, 'icu'], ['u', 899, 1379, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2319, 2799, 'rn'], ['u', 1079, 1319, 'icu'], ['t', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['overlap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']],
     'b': [['v', 2339, 2579, 'rn'], ['t', 60, 660, 'rn'], ['u', 1259, 1739, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1440],
   ['overlap', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('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': [['s', 60, 300, 'icu']],
     'b': [['t', 0, 600, 'icu'], ['v', 2900, 3500, 'rn'], ['u', 1300, 1900, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['t', 60, 660, 'icu'], ['v', 2740, 3340, 'rn'], ['u', 1660, 2140, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 7',
   [{'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']),
  ('normal control 8',
   [{'a': [['s', 60, 660, 'rn'], ['t', 960, 1440, 'icu']], 'b': [['u', 60, 660, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 960],
   ['qual', 'a'])],
 [('regression: cap uses post swap roster 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: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'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']),
  ('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': [['s', 60, 540, 'rn'], ['t', 840, 1320, 'icu']],
     'b': [['u', 60, 660, 'rn'], ['v', 1660, 1900, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 6',
   [{'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']),
  ('normal control 7',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1540, 2020, 'icu']],
     'b': [['u', 60, 540, 'icu'], ['v', 1140, 1620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('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: cap uses post swap roster 1',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1780, 'icu'], ['u', 2380, 2620, 'rn'], ['s', 60, 300, 'rn']],
     'b': [['w', 1300, 1780, 'rn'], ['v', 0, 600, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('boundary control 4',
   [{'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 5',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn']],
     'b': [['u', 0, 600, 'rn'], ['w', 2279, 2759, 'rn'], ['v', 1200, 1680, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['v', 2380, 2980, 'rn'], ['t', 0, 600, 'rn'], ['u', 1300, 1780, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['qual', '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: cap uses post swap roster 1['cap', 'a']['ok', None]Failed
regression variant: cap uses post swap roster 2['cap', 'b']['ok', None]Failed
boundary control 3['cap', 'b']['ok', None]Failed
normal control 4['rest', 'a']['rest', 'a']Passed
normal control 5['qual', 'b']['qual', 'b']Passed
normal control 6['rest', 'a']['rest', 'a']Passed
normal control 7['overlap', 'b']['overlap', 'b']Passed
normal control 8['qual', 'b']['qual', 'b']Passed

SHA-256 / 26118d3be105dccea931b9d7819a3bf6a1a47e3ced1581c84544712f65e6bc7f

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[2] < rest:
                return ['rest', w]
    for w in (a, b):
        if sum(t[2] - t[1] for t in roster[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: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('boundary control 3',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'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']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu'], ['t', 1199, 1679, 'rn'], ['u', 1979, 2579, 'icu']],
     'b': [['v', 60, 540, 'icu'], ['x', 2440, 2680, 'rn'], ['w', 1240, 1840, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'x'], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'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 7',
   [{'a': [['s', 60, 540, 'rn']], 'b': [['u', 1260, 1740, 'icu'], ['t', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['t', 1540, 2020, 'rn'], ['s', 60, 540, 'icu']],
     'b': [['w', 2279, 2759, 'rn'], ['u', 0, 600, 'rn'], ['v', 1199, 1679, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1240, 1720, 'rn']], 'b': [['u', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['s', 60, 300, 'icu']],
     'b': [['t', 60, 660, 'rn'], ['u', 1660, 2140, 'icu'], ['v', 3140, 3620, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']], 'b': [['t', 60, 300, 'icu'], ['u', 899, 1379, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2319, 2799, 'rn'], ['u', 1079, 1319, 'icu'], ['t', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['overlap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']],
     'b': [['v', 2339, 2579, 'rn'], ['t', 60, 660, 'rn'], ['u', 1259, 1739, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1440],
   ['overlap', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('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': [['s', 60, 300, 'icu']],
     'b': [['t', 0, 600, 'icu'], ['v', 2900, 3500, 'rn'], ['u', 1300, 1900, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['t', 60, 660, 'icu'], ['v', 2740, 3340, 'rn'], ['u', 1660, 2140, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 7',
   [{'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']),
  ('normal control 8',
   [{'a': [['s', 60, 660, 'rn'], ['t', 960, 1440, 'icu']], 'b': [['u', 60, 660, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 960],
   ['qual', 'a'])],
 [('regression: cap uses post swap roster 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: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'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']),
  ('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': [['s', 60, 540, 'rn'], ['t', 840, 1320, 'icu']],
     'b': [['u', 60, 660, 'rn'], ['v', 1660, 1900, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 6',
   [{'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']),
  ('normal control 7',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1540, 2020, 'icu']],
     'b': [['u', 60, 540, 'icu'], ['v', 1140, 1620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('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: cap uses post swap roster 1',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1780, 'icu'], ['u', 2380, 2620, 'rn'], ['s', 60, 300, 'rn']],
     'b': [['w', 1300, 1780, 'rn'], ['v', 0, 600, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('boundary control 4',
   [{'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 5',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn']],
     'b': [['u', 0, 600, 'rn'], ['w', 2279, 2759, 'rn'], ['v', 1200, 1680, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['v', 2380, 2980, 'rn'], ['t', 0, 600, 'rn'], ['u', 1300, 1780, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['qual', '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: cap uses post swap roster 1['cap', 'a']['ok', None]Failed
regression variant: cap uses post swap roster 2['cap', 'b']['ok', None]Failed
boundary control 3['ok', None]['ok', None]Passed
normal control 4['rest', 'a']['rest', 'a']Passed
normal control 5['qual', 'b']['qual', 'b']Passed
normal control 6['rest', 'a']['rest', 'a']Passed
normal control 7['overlap', 'b']['overlap', 'b']Passed
normal control 8['qual', 'b']['qual', 'b']Passed

SHA-256 / e1388bc56d869f2b3d4b0f35bdae709a2b166660fa14baf59c1f3523992d3087

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: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('boundary control 3',
   [{'a': [['s', 0, 480, 'rn']], 'b': [['u', 1080, 1560, 'rn']]}, {'a': ['rn'], 'b': ['rn']},
    ['a', 'b', 's', None], 600, 960],
   ['ok', None]),
  ('normal control 4',
   [{'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']),
  ('normal control 5',
   [{'a': [['s', 0, 600, 'icu'], ['t', 1199, 1679, 'rn'], ['u', 1979, 2579, 'icu']],
     'b': [['v', 60, 540, 'icu'], ['x', 2440, 2680, 'rn'], ['w', 1240, 1840, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'x'], 600, 1200],
   ['qual', 'b']),
  ('normal control 6',
   [{'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 7',
   [{'a': [['s', 60, 540, 'rn']], 'b': [['u', 1260, 1740, 'icu'], ['t', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1440],
   ['overlap', 'b']),
  ('normal control 8',
   [{'a': [['t', 1540, 2020, 'rn'], ['s', 60, 540, 'icu']],
     'b': [['w', 2279, 2759, 'rn'], ['u', 0, 600, 'rn'], ['v', 1199, 1679, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1240, 1720, 'rn']], 'b': [['u', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', None], 600, 960],
   ['ok', None]),
  ('partial repair guard 3',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('normal control 4',
   [{'a': [['s', 60, 300, 'icu']],
     'b': [['t', 60, 660, 'rn'], ['u', 1660, 2140, 'icu'], ['v', 3140, 3620, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['qual', 'b']),
  ('normal control 5',
   [{'a': [['s', 0, 240, 'icu']], 'b': [['t', 60, 300, 'icu'], ['u', 899, 1379, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['s', 0, 600, 'icu']],
     'b': [['v', 2319, 2799, 'rn'], ['u', 1079, 1319, 'icu'], ['t', 0, 480, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'v'], 600, 960],
   ['overlap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 600, 'rn']],
     'b': [['v', 2339, 2579, 'rn'], ['t', 60, 660, 'rn'], ['u', 1259, 1739, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', 'u'], 600, 1440],
   ['overlap', 'b'])],
 [('regression: cap uses post swap roster 1',
   [{'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]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('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': [['s', 60, 300, 'icu']],
     'b': [['t', 0, 600, 'icu'], ['v', 2900, 3500, 'rn'], ['u', 1300, 1900, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'u'], 600, 960],
   ['qual', 'a']),
  ('normal control 6',
   [{'a': [['s', 0, 240, 'rn']],
     'b': [['t', 60, 660, 'icu'], ['v', 2740, 3340, 'rn'], ['u', 1660, 2140, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['overlap', 'b']),
  ('normal control 7',
   [{'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']),
  ('normal control 8',
   [{'a': [['s', 60, 660, 'rn'], ['t', 960, 1440, 'icu']], 'b': [['u', 60, 660, 'icu']]},
    {'a': ['rn'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 960],
   ['qual', 'a'])],
 [('regression: cap uses post swap roster 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: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'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']),
  ('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': [['s', 60, 540, 'rn'], ['t', 840, 1320, 'icu']],
     'b': [['u', 60, 660, 'rn'], ['v', 1660, 1900, 'icu']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 't', 'u'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 6',
   [{'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']),
  ('normal control 7',
   [{'a': [['s', 60, 540, 'rn'], ['t', 1540, 2020, 'icu']],
     'b': [['u', 60, 540, 'icu'], ['v', 1140, 1620, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 1200],
   ['overlap', 'b']),
  ('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: cap uses post swap roster 1',
   [{'a': [['s', 0, 480, 'rn']],
     'b': [['v', 2679, 2919, 'rn'], ['t', 0, 600, 'rn'], ['u', 1199, 1679, 'rn']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 't'], 600, 1200],
   ['ok', None]),
  ('regression variant: cap uses post swap roster 2',
   [{'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]),
  ('partial repair guard 3',
   [{'a': [['t', 1300, 1780, 'icu'], ['u', 2380, 2620, 'rn'], ['s', 60, 300, 'rn']],
     'b': [['w', 1300, 1780, 'rn'], ['v', 0, 600, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['rn', 'icu']}, ['a', 'b', 's', 'v'], 600, 1200],
   ['cap', 'a']),
  ('boundary control 4',
   [{'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 5',
   [{'a': [['t', 1240, 1720, 'icu'], ['s', 0, 240, 'rn']],
     'b': [['u', 0, 600, 'rn'], ['w', 2279, 2759, 'rn'], ['v', 1200, 1680, 'icu']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 's', None], 600, 960],
   ['overlap', 'b']),
  ('normal control 6',
   [{'a': [['t', 1300, 1900, 'icu'], ['s', 60, 300, 'rn']], 'b': [['u', 60, 540, 'rn']]},
    {'a': ['rn'], 'b': ['icu', 'rn']}, ['a', 'b', 't', None], 600, 960],
   ['cap', 'b']),
  ('normal control 7',
   [{'a': [['s', 0, 600, 'rn'], ['u', 3200, 3440, 'rn'], ['t', 1600, 2200, 'rn']],
     'b': [['v', 60, 660, 'rn']]},
    {'a': ['rn', 'icu'], 'b': ['icu', 'rn']}, ['a', 'b', 'u', 'v'], 600, 1200],
   ['overlap', 'a']),
  ('normal control 8',
   [{'a': [['s', 0, 480, 'icu']],
     'b': [['v', 2380, 2980, 'rn'], ['t', 0, 600, 'rn'], ['u', 1300, 1780, 'icu']]},
    {'a': ['rn'], 'b': ['rn']}, ['a', 'b', 's', 'v'], 600, 1440],
   ['qual', '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: cap uses post swap roster 1['ok', None]['ok', None]Passed
regression variant: cap uses post swap roster 2['ok', None]['ok', None]Passed
boundary control 3['ok', None]['ok', None]Passed
normal control 4['rest', 'a']['rest', 'a']Passed
normal control 5['qual', 'b']['qual', 'b']Passed
normal control 6['rest', 'a']['rest', 'a']Passed
normal control 7['overlap', 'b']['overlap', 'b']Passed
normal control 8['qual', 'b']['qual', 'b']Passed

SHA-256 / 5706bc4896eb916fcd598e8f03abfd8aa278f722eb634a806e5d2a439cb3fbde

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

Case digest / 2807b89a4d1dc624c0b9114b1f571a21a5db1c93e282b65244f26479cc974d9d