{"abstract":"Bags that run out during the final rate are reported as never emptying.","category":"Medication dosing calculations","checks":9,"contract":"Input {bag_ml, segments [[start_min, rate_ml_h], ...] ascending from 0}. Each segment runs until the next start; the last segment is open-ended. Paused segments (rate 0) consume nothing. Return {empty_min, alarm_min = max(0, empty-30)} rounded to 0.1 min, or both None when the bag never empties.","evaluation_group":"w2-meddose-bag-runout","failed_approach":"Capping the last segment at 24 hours misses slow infusions that empty later.","family":"w2-meddose-bag-runout-open-ended-final-segment","id":"FA-64316","implementations":{"attempt":{"sha256":"b050c127208bdfedd7a2e7f9d0be4ad51d1253737b0de56246dd2381a67a03ac","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    left = Fraction(x['bag_ml'])\n    segs = x['segments']\n    for i, (t0, rate) in enumerate(segs):\n        t1 = segs[i + 1][0] if i + 1 < len(segs) else 1440\n        if rate == 0:\n            continue\n        per_min = Fraction(rate, 60)\n        need = left / per_min\n        if t1 is None or t0 + need <= t1:\n            empty = t0 + need\n            return {'empty_min': round(float(empty), 1), 'alarm_min': round(float(max(Fraction(0), empty - 30)), 1)}\n        left -= per_min * (t1 - t0)\n    return {'empty_min': None, 'alarm_min': None}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('single rate', {'bag_ml': 500, 'segments': [[0, 125]]}, {'empty_min': 240.0, 'alarm_min': 210.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 260]]},\n   {'empty_min': 355.4, 'alarm_min': 325.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [150, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 110, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 31]]},\n   {'empty_min': 272.9, 'alarm_min': 242.9}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 80]]},\n   {'empty_min': 15.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 30]]},\n   {'empty_min': 230.0, 'alarm_min': 200.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 11]]},\n   {'empty_min': 5241.8, 'alarm_min': 5211.8})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 150]]}, {'empty_min': 200.0, 'alarm_min': 170.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 270]]},\n   {'empty_min': 351.1, 'alarm_min': 321.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [180, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 120, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 32]]},\n   {'empty_min': 266.2, 'alarm_min': 236.2}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 100]]},\n   {'empty_min': 12.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 60]]},\n   {'empty_min': 160.0, 'alarm_min': 130.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 12]]},\n   {'empty_min': 4810.0, 'alarm_min': 4780.0})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 175]]}, {'empty_min': 171.4, 'alarm_min': 141.4}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 280]]},\n   {'empty_min': 347.1, 'alarm_min': 317.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [210, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 130, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 33]]},\n   {'empty_min': 260.0, 'alarm_min': 230.0}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 120]]},\n   {'empty_min': 10.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 90]]},\n   {'empty_min': 136.7, 'alarm_min': 106.7}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 13]]},\n   {'empty_min': 4444.6, 'alarm_min': 4414.6})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 200]]}, {'empty_min': 150.0, 'alarm_min': 120.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 290]]},\n   {'empty_min': 343.4, 'alarm_min': 313.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [240, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 140, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 34]]},\n   {'empty_min': 254.1, 'alarm_min': 224.1}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 140]]},\n   {'empty_min': 8.6, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 120]]},\n   {'empty_min': 125.0, 'alarm_min': 95.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 14]]},\n   {'empty_min': 4131.4, 'alarm_min': 4101.4})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 225]]}, {'empty_min': 133.3, 'alarm_min': 103.3}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 300]]},\n   {'empty_min': 340.0, 'alarm_min': 310.0}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [270, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 150, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 35]]},\n   {'empty_min': 248.6, 'alarm_min': 218.6}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 160]]},\n   {'empty_min': 7.5, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 150]]},\n   {'empty_min': 118.0, 'alarm_min': 88.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 15]]},\n   {'empty_min': 3860.0, 'alarm_min': 3830.0})]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"c7c720ecfb719351268dd8354cd0f3ae3d5887032c38164332d1edf7382d5004","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    left = Fraction(x['bag_ml'])\n    segs = x['segments']\n    for i, (t0, rate) in enumerate(segs):\n        t1 = segs[i + 1][0] if i + 1 < len(segs) else t0\n        if rate == 0:\n            continue\n        per_min = Fraction(rate, 60)\n        need = left / per_min\n        if t1 is None or t0 + need <= t1:\n            empty = t0 + need\n            return {'empty_min': round(float(empty), 1), 'alarm_min': round(float(max(Fraction(0), empty - 30)), 1)}\n        left -= per_min * (t1 - t0)\n    return {'empty_min': None, 'alarm_min': None}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('single rate', {'bag_ml': 500, 'segments': [[0, 125]]}, {'empty_min': 240.0, 'alarm_min': 210.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 260]]},\n   {'empty_min': 355.4, 'alarm_min': 325.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [150, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 110, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 31]]},\n   {'empty_min': 272.9, 'alarm_min': 242.9}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 80]]},\n   {'empty_min': 15.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 30]]},\n   {'empty_min': 230.0, 'alarm_min': 200.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 11]]},\n   {'empty_min': 5241.8, 'alarm_min': 5211.8})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 150]]}, {'empty_min': 200.0, 'alarm_min': 170.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 270]]},\n   {'empty_min': 351.1, 'alarm_min': 321.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [180, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 120, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 32]]},\n   {'empty_min': 266.2, 'alarm_min': 236.2}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 100]]},\n   {'empty_min': 12.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 60]]},\n   {'empty_min': 160.0, 'alarm_min': 130.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 12]]},\n   {'empty_min': 4810.0, 'alarm_min': 4780.0})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 175]]}, {'empty_min': 171.4, 'alarm_min': 141.4}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 280]]},\n   {'empty_min': 347.1, 'alarm_min': 317.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [210, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 130, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 33]]},\n   {'empty_min': 260.0, 'alarm_min': 230.0}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 120]]},\n   {'empty_min': 10.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 90]]},\n   {'empty_min': 136.7, 'alarm_min': 106.7}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 13]]},\n   {'empty_min': 4444.6, 'alarm_min': 4414.6})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 200]]}, {'empty_min': 150.0, 'alarm_min': 120.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 290]]},\n   {'empty_min': 343.4, 'alarm_min': 313.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [240, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 140, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 34]]},\n   {'empty_min': 254.1, 'alarm_min': 224.1}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 140]]},\n   {'empty_min': 8.6, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 120]]},\n   {'empty_min': 125.0, 'alarm_min': 95.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 14]]},\n   {'empty_min': 4131.4, 'alarm_min': 4101.4})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 225]]}, {'empty_min': 133.3, 'alarm_min': 103.3}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 300]]},\n   {'empty_min': 340.0, 'alarm_min': 310.0}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [270, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 150, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 35]]},\n   {'empty_min': 248.6, 'alarm_min': 218.6}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 160]]},\n   {'empty_min': 7.5, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 150]]},\n   {'empty_min': 118.0, 'alarm_min': 88.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 15]]},\n   {'empty_min': 3860.0, 'alarm_min': 3830.0})]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"cbb41fa490a85e762772542c51ce7ddfa4fdef8ba989c6a6780c3a2b383702d4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    left = Fraction(x['bag_ml'])\n    segs = x['segments']\n    for i, (t0, rate) in enumerate(segs):\n        t1 = segs[i + 1][0] if i + 1 < len(segs) else None\n        if rate == 0:\n            continue\n        per_min = Fraction(rate, 60)\n        need = left / per_min\n        if t1 is None or t0 + need <= t1:\n            empty = t0 + need\n            return {'empty_min': round(float(empty), 1), 'alarm_min': round(float(max(Fraction(0), empty - 30)), 1)}\n        left -= per_min * (t1 - t0)\n    return {'empty_min': None, 'alarm_min': None}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('single rate', {'bag_ml': 500, 'segments': [[0, 125]]}, {'empty_min': 240.0, 'alarm_min': 210.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 260]]},\n   {'empty_min': 355.4, 'alarm_min': 325.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [150, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 110, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 31]]},\n   {'empty_min': 272.9, 'alarm_min': 242.9}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 80]]},\n   {'empty_min': 15.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 30]]},\n   {'empty_min': 230.0, 'alarm_min': 200.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 11]]},\n   {'empty_min': 5241.8, 'alarm_min': 5211.8})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 150]]}, {'empty_min': 200.0, 'alarm_min': 170.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 270]]},\n   {'empty_min': 351.1, 'alarm_min': 321.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [180, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 120, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 32]]},\n   {'empty_min': 266.2, 'alarm_min': 236.2}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 100]]},\n   {'empty_min': 12.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 60]]},\n   {'empty_min': 160.0, 'alarm_min': 130.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 12]]},\n   {'empty_min': 4810.0, 'alarm_min': 4780.0})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 175]]}, {'empty_min': 171.4, 'alarm_min': 141.4}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 280]]},\n   {'empty_min': 347.1, 'alarm_min': 317.1}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [210, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 130, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 33]]},\n   {'empty_min': 260.0, 'alarm_min': 230.0}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 120]]},\n   {'empty_min': 10.0, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 90]]},\n   {'empty_min': 136.7, 'alarm_min': 106.7}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 13]]},\n   {'empty_min': 4444.6, 'alarm_min': 4414.6})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 200]]}, {'empty_min': 150.0, 'alarm_min': 120.0}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 290]]},\n   {'empty_min': 343.4, 'alarm_min': 313.4}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [240, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 140, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 34]]},\n   {'empty_min': 254.1, 'alarm_min': 224.1}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 140]]},\n   {'empty_min': 8.6, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 120]]},\n   {'empty_min': 125.0, 'alarm_min': 95.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 14]]},\n   {'empty_min': 4131.4, 'alarm_min': 4101.4})],\n [('single rate', {'bag_ml': 500, 'segments': [[0, 225]]}, {'empty_min': 133.3, 'alarm_min': 103.3}),\n  ('rate change mid bag',\n   {'bag_ml': 1000, 'segments': [[0, 125], [240, 300]]},\n   {'empty_min': 340.0, 'alarm_min': 310.0}),\n  ('empties exactly at pause',\n   {'bag_ml': 250, 'segments': [[0, 125], [120, 0], [270, 60]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('empties exactly at end of final paused tail',\n   {'bag_ml': 100, 'segments': [[0, 50], [120, 0]]},\n   {'empty_min': 120.0, 'alarm_min': 90.0}),\n  ('bag outlasts second segment before pause',\n   {'bag_ml': 150, 'segments': [[0, 60], [60, 60], [100, 0]]},\n   {'empty_min': None, 'alarm_min': None}),\n  ('completed middle segment consumption',\n   {'bag_ml': 200, 'segments': [[0, 60], [30, 120], [60, 35]]},\n   {'empty_min': 248.6, 'alarm_min': 218.6}),\n  ('small bag alarm clamps at zero',\n   {'bag_ml': 20, 'segments': [[0, 160]]},\n   {'empty_min': 7.5, 'alarm_min': 0.0}),\n  ('pause then resume',\n   {'bag_ml': 100, 'segments': [[0, 60], [30, 0], [90, 150]]},\n   {'empty_min': 118.0, 'alarm_min': 88.0}),\n  ('very slow multi-day tail',\n   {'bag_ml': 1000, 'segments': [[0, 50], [60, 15]]},\n   {'empty_min': 3860.0, 'alarm_min': 3830.0})]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic toy software model with explicitly stipulated thresholds and formulas; it is not clinical guidance, not a validated medical calculator, and makes no claim of conformance to any published protocol. Numbered variants vary patient and order inputs. 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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-meddose-bag-runout-open-ended-final-segment","generated_at":"2026-09-29T14:47:23.263462+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Run-out prediction walks piecewise-constant rates; segment edges, open-ended tails and unit conversion fail independently.","repair":"Accept run-out in the last segment regardless of time.","root_cause":"The final segment is given a zero length (it ends where it starts), so it never consumes volume.","sha256":"63477bc1534e7122cc60200f3c007f6936b1d66d04ccaecf9a8fbd615875bd60","title":"Infusion bag run-out time across rate changes: open-ended final segment · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":43.549,"exit_code":1,"observations":[{"actual":{"alarm_min":210.0,"empty_min":240.0},"check":"single rate","expected":{"alarm_min":210.0,"empty_min":240.0},"passed":true},{"actual":{"alarm_min":325.4,"empty_min":355.4},"check":"rate change mid bag","expected":{"alarm_min":325.4,"empty_min":355.4},"passed":true},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at pause","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at end of final paused tail","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":null,"empty_min":null},"check":"bag outlasts second segment before pause","expected":{"alarm_min":null,"empty_min":null},"passed":true},{"actual":{"alarm_min":242.9,"empty_min":272.9},"check":"completed middle segment consumption","expected":{"alarm_min":242.9,"empty_min":272.9},"passed":true},{"actual":{"alarm_min":0.0,"empty_min":15.0},"check":"small bag alarm clamps at zero","expected":{"alarm_min":0.0,"empty_min":15.0},"passed":true},{"actual":{"alarm_min":200.0,"empty_min":230.0},"check":"pause then resume","expected":{"alarm_min":200.0,"empty_min":230.0},"passed":true},{"actual":{"alarm_min":null,"empty_min":null},"check":"very slow multi-day tail","expected":{"alarm_min":5211.8,"empty_min":5241.8},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"single rate\", \"actual\": {\"empty_min\": 240.0, \"alarm_min\": 210.0}, \"expected\": {\"empty_min\": 240.0, \"alarm_min\": 210.0}, \"passed\": true}, {\"check\": \"rate change mid bag\", \"actual\": {\"empty_min\": 355.4, \"alarm_min\": 325.4}, \"expected\": {\"empty_min\": 355.4, \"alarm_min\": 325.4}, \"passed\": true}, {\"check\": \"empties exactly at pause\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"empties exactly at end of final paused tail\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"bag outlasts second segment before pause\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": null, \"alarm_min\": null}, \"passed\": true}, {\"check\": \"completed middle segment consumption\", \"actual\": {\"empty_min\": 272.9, \"alarm_min\": 242.9}, \"expected\": {\"empty_min\": 272.9, \"alarm_min\": 242.9}, \"passed\": true}, {\"check\": \"small bag alarm clamps at zero\", \"actual\": {\"empty_min\": 15.0, \"alarm_min\": 0.0}, \"expected\": {\"empty_min\": 15.0, \"alarm_min\": 0.0}, \"passed\": true}, {\"check\": \"pause then resume\", \"actual\": {\"empty_min\": 230.0, \"alarm_min\": 200.0}, \"expected\": {\"empty_min\": 230.0, \"alarm_min\": 200.0}, \"passed\": true}, {\"check\": \"very slow multi-day tail\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 5241.8, \"alarm_min\": 5211.8}, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.202,"exit_code":1,"observations":[{"actual":{"alarm_min":null,"empty_min":null},"check":"single rate","expected":{"alarm_min":210.0,"empty_min":240.0},"passed":false},{"actual":{"alarm_min":null,"empty_min":null},"check":"rate change mid bag","expected":{"alarm_min":325.4,"empty_min":355.4},"passed":false},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at pause","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at end of final paused tail","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":null,"empty_min":null},"check":"bag outlasts second segment before pause","expected":{"alarm_min":null,"empty_min":null},"passed":true},{"actual":{"alarm_min":null,"empty_min":null},"check":"completed middle segment consumption","expected":{"alarm_min":242.9,"empty_min":272.9},"passed":false},{"actual":{"alarm_min":null,"empty_min":null},"check":"small bag alarm clamps at zero","expected":{"alarm_min":0.0,"empty_min":15.0},"passed":false},{"actual":{"alarm_min":null,"empty_min":null},"check":"pause then resume","expected":{"alarm_min":200.0,"empty_min":230.0},"passed":false},{"actual":{"alarm_min":null,"empty_min":null},"check":"very slow multi-day tail","expected":{"alarm_min":5211.8,"empty_min":5241.8},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"single rate\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 240.0, \"alarm_min\": 210.0}, \"passed\": false}, {\"check\": \"rate change mid bag\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 355.4, \"alarm_min\": 325.4}, \"passed\": false}, {\"check\": \"empties exactly at pause\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"empties exactly at end of final paused tail\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"bag outlasts second segment before pause\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": null, \"alarm_min\": null}, \"passed\": true}, {\"check\": \"completed middle segment consumption\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 272.9, \"alarm_min\": 242.9}, \"passed\": false}, {\"check\": \"small bag alarm clamps at zero\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 15.0, \"alarm_min\": 0.0}, \"passed\": false}, {\"check\": \"pause then resume\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 230.0, \"alarm_min\": 200.0}, \"passed\": false}, {\"check\": \"very slow multi-day tail\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": 5241.8, \"alarm_min\": 5211.8}, \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":46.766,"exit_code":0,"observations":[{"actual":{"alarm_min":210.0,"empty_min":240.0},"check":"single rate","expected":{"alarm_min":210.0,"empty_min":240.0},"passed":true},{"actual":{"alarm_min":325.4,"empty_min":355.4},"check":"rate change mid bag","expected":{"alarm_min":325.4,"empty_min":355.4},"passed":true},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at pause","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":90.0,"empty_min":120.0},"check":"empties exactly at end of final paused tail","expected":{"alarm_min":90.0,"empty_min":120.0},"passed":true},{"actual":{"alarm_min":null,"empty_min":null},"check":"bag outlasts second segment before pause","expected":{"alarm_min":null,"empty_min":null},"passed":true},{"actual":{"alarm_min":242.9,"empty_min":272.9},"check":"completed middle segment consumption","expected":{"alarm_min":242.9,"empty_min":272.9},"passed":true},{"actual":{"alarm_min":0.0,"empty_min":15.0},"check":"small bag alarm clamps at zero","expected":{"alarm_min":0.0,"empty_min":15.0},"passed":true},{"actual":{"alarm_min":200.0,"empty_min":230.0},"check":"pause then resume","expected":{"alarm_min":200.0,"empty_min":230.0},"passed":true},{"actual":{"alarm_min":5211.8,"empty_min":5241.8},"check":"very slow multi-day tail","expected":{"alarm_min":5211.8,"empty_min":5241.8},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"single rate\", \"actual\": {\"empty_min\": 240.0, \"alarm_min\": 210.0}, \"expected\": {\"empty_min\": 240.0, \"alarm_min\": 210.0}, \"passed\": true}, {\"check\": \"rate change mid bag\", \"actual\": {\"empty_min\": 355.4, \"alarm_min\": 325.4}, \"expected\": {\"empty_min\": 355.4, \"alarm_min\": 325.4}, \"passed\": true}, {\"check\": \"empties exactly at pause\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"empties exactly at end of final paused tail\", \"actual\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"expected\": {\"empty_min\": 120.0, \"alarm_min\": 90.0}, \"passed\": true}, {\"check\": \"bag outlasts second segment before pause\", \"actual\": {\"empty_min\": null, \"alarm_min\": null}, \"expected\": {\"empty_min\": null, \"alarm_min\": null}, \"passed\": true}, {\"check\": \"completed middle segment consumption\", \"actual\": {\"empty_min\": 272.9, \"alarm_min\": 242.9}, \"expected\": {\"empty_min\": 272.9, \"alarm_min\": 242.9}, \"passed\": true}, {\"check\": \"small bag alarm clamps at zero\", \"actual\": {\"empty_min\": 15.0, \"alarm_min\": 0.0}, \"expected\": {\"empty_min\": 15.0, \"alarm_min\": 0.0}, \"passed\": true}, {\"check\": \"pause then resume\", \"actual\": {\"empty_min\": 230.0, \"alarm_min\": 200.0}, \"expected\": {\"empty_min\": 230.0, \"alarm_min\": 200.0}, \"passed\": true}, {\"check\": \"very slow multi-day tail\", \"actual\": {\"empty_min\": 5241.8, \"alarm_min\": 5211.8}, \"expected\": {\"empty_min\": 5241.8, \"alarm_min\": 5211.8}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}