{"abstract":"A 7.3 unit maximum produces a 7.3 unit dose that the pen cannot deliver.","category":"Medication dosing calculations","checks":8,"contract":"Input {bg, target, isf, carbs_g, icr, iob, max_units}. Toy rule: bg < 70 returns HOLD with 0 units. correction = (bg-target)/isf; when positive, insulin on board is subtracted from it and the result floored at 0; a negative correction (bg below target) is kept and reduces the meal dose. meal = carbs_g/icr. total = max(0, meal + correction), capped at max_units, then rounded DOWN to 0.5 units. Return {action GIVE|HOLD, units}.","evaluation_group":"w2-meddose-insulin-bolus","failed_approach":"Capping at the whole-unit floor of the maximum loses a deliverable half unit (7.8 maximum gives 7 instead of 7.5).","family":"w2-meddose-insulin-bolus-cap-before-pen-rounding","id":"FA-63996","implementations":{"attempt":{"sha256":"1c86da66daa40139daf1cd546098dddca47dc88c2d695652898dfa6af62005c3","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    bg, tgt = x['bg'], x['target']\n    if bg < 70:\n        return {'action': 'HOLD', 'units': 0.0}\n    corr = Fraction(bg - tgt, x['isf'])\n    if corr > 0:\n        corr = max(Fraction(0), corr - Fraction(str(x['iob'])))\n    meal = Fraction(x['carbs_g'], x['icr'])\n    total = max(Fraction(0), meal + corr)\n    units = Fraction(math.floor(total * 2), 2)\n    units = min(units, Fraction(math.floor(Fraction(str(x['max_units']))), 1))\n    return {'action': 'GIVE', 'units': float(units)}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('low glucose with meal is held',\n   {'bg': 61, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 65, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 40, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 59, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.8'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 11},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 62, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 2, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 49, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.6'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 12},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 63, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 75, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 38, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 3.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '4.7'},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 13},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 64, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 4, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 69, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '6.9'},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 14},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 65, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 90, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 85, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 5, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 29, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '10.6'},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.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":"e24e1600d83ade44b215066163ed22fb01ab436fd5f2b24d31e4137515241b24","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    bg, tgt = x['bg'], x['target']\n    if bg < 70:\n        return {'action': 'HOLD', 'units': 0.0}\n    corr = Fraction(bg - tgt, x['isf'])\n    if corr > 0:\n        corr = max(Fraction(0), corr - Fraction(str(x['iob'])))\n    meal = Fraction(x['carbs_g'], x['icr'])\n    total = max(Fraction(0), meal + corr)\n    units = min(Fraction(math.floor(total * 2), 2), Fraction(str(x['max_units'])))\n    return {'action': 'GIVE', 'units': float(units)}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('low glucose with meal is held',\n   {'bg': 61, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 65, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 40, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 59, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.8'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 11},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 62, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 2, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 49, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.6'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 12},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 63, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 75, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 38, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 3.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '4.7'},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 13},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 64, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 4, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 69, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '6.9'},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 14},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 65, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 90, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 85, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 5, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 29, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '10.6'},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.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":"83a53204570077d92ce524dde2f25d1630a6f0850a027abf8e070f15326367b8","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    bg, tgt = x['bg'], x['target']\n    if bg < 70:\n        return {'action': 'HOLD', 'units': 0.0}\n    corr = Fraction(bg - tgt, x['isf'])\n    if corr > 0:\n        corr = max(Fraction(0), corr - Fraction(str(x['iob'])))\n    meal = Fraction(x['carbs_g'], x['icr'])\n    total = max(Fraction(0), meal + corr)\n    total = min(total, Fraction(str(x['max_units'])))\n    units = Fraction(math.floor(total * 2), 2)\n    return {'action': 'GIVE', 'units': float(units)}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('low glucose with meal is held',\n   {'bg': 61, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 65, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 40, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 59, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.8'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 11},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 62, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 2, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 5.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 49, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '7.6'},\n   {'action': 'GIVE', 'units': 7.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 12},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 63, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 75, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 9.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 60, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 38, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 3.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '4.7'},\n   {'action': 'GIVE', 'units': 4.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 13},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 64, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.0}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 4, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 70, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 7.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 69, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '6.9'},\n   {'action': 'GIVE', 'units': 6.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 14},\n   {'action': 'GIVE', 'units': 2.0})],\n [('low glucose with meal is held',\n   {'bg': 65, 'target': 110, 'isf': 40, 'carbs_g': 45, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'HOLD', 'units': 0.0}),\n  ('glucose exactly 70 is dosed',\n   {'bg': 70, 'target': 110, 'isf': 40, 'carbs_g': 90, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('high glucose with insulin on board',\n   {'bg': 250, 'target': 120, 'isf': 40, 'carbs_g': 85, 'icr': 10, 'iob': 1, 'max_units': 15},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('below target with insulin on board',\n   {'bg': 90, 'target': 120, 'isf': 30, 'carbs_g': 50, 'icr': 10, 'iob': 5, 'max_units': 15},\n   {'action': 'GIVE', 'units': 4.0}),\n  ('insulin on board exceeds correction',\n   {'bg': 160, 'target': 120, 'isf': 40, 'carbs_g': 80, 'icr': 10, 'iob': 3, 'max_units': 15},\n   {'action': 'GIVE', 'units': 8.0}),\n  ('pen resolution rounds down',\n   {'bg': 120, 'target': 120, 'isf': 40, 'carbs_g': 29, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.5}),\n  ('maximum bolus cap not on half unit',\n   {'bg': 200, 'target': 120, 'isf': 40, 'carbs_g': 120, 'icr': 10, 'iob': 0, 'max_units': '10.6'},\n   {'action': 'GIVE', 'units': 10.5}),\n  ('correction only control',\n   {'bg': 200, 'target': 100, 'isf': 50, 'carbs_g': 0, 'icr': 10, 'iob': 0, 'max_units': 15},\n   {'action': 'GIVE', 'units': 2.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-insulin-bolus-cap-before-pen-rounding","generated_at":"2026-09-29T14:47:19.975699+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Bolus calculators combine several unit ratios and safety rules; insulin-on-board, hypoglycaemia holds and pen resolution are separate decision points.","repair":"Cap the total first and then round down to 0.5 units.","root_cause":"The maximum is applied after rounding, reintroducing a non-half-unit value.","sha256":"2510db236d0848888958beeaaab8dc19cc08f7ce3aebad14a177484a8b8acf49","title":"Meal and correction insulin bolus with insulin on board: cap before pen rounding · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.864,"exit_code":1,"observations":[{"actual":{"action":"HOLD","units":0.0},"check":"low glucose with meal is held","expected":{"action":"HOLD","units":0.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"glucose exactly 70 is dosed","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":8.5},"check":"high glucose with insulin on board","expected":{"action":"GIVE","units":8.5},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"below target with insulin on board","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"insulin on board exceeds correction","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":5.5},"check":"pen resolution rounds down","expected":{"action":"GIVE","units":5.5},"passed":true},{"actual":{"action":"GIVE","units":7.0},"check":"maximum bolus cap not on half unit","expected":{"action":"GIVE","units":7.5},"passed":false},{"actual":{"action":"GIVE","units":2.0},"check":"correction only control","expected":{"action":"GIVE","units":2.0},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"low glucose with meal is held\", \"actual\": {\"action\": \"HOLD\", \"units\": 0.0}, \"expected\": {\"action\": \"HOLD\", \"units\": 0.0}, \"passed\": true}, {\"check\": \"glucose exactly 70 is dosed\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"high glucose with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 8.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 8.5}, \"passed\": true}, {\"check\": \"below target with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"insulin on board exceeds correction\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"pen resolution rounds down\", \"actual\": {\"action\": \"GIVE\", \"units\": 5.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 5.5}, \"passed\": true}, {\"check\": \"maximum bolus cap not on half unit\", \"actual\": {\"action\": \"GIVE\", \"units\": 7.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 7.5}, \"passed\": false}, {\"check\": \"correction only control\", \"actual\": {\"action\": \"GIVE\", \"units\": 2.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 2.0}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":44.697,"exit_code":1,"observations":[{"actual":{"action":"HOLD","units":0.0},"check":"low glucose with meal is held","expected":{"action":"HOLD","units":0.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"glucose exactly 70 is dosed","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":8.5},"check":"high glucose with insulin on board","expected":{"action":"GIVE","units":8.5},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"below target with insulin on board","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"insulin on board exceeds correction","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":5.5},"check":"pen resolution rounds down","expected":{"action":"GIVE","units":5.5},"passed":true},{"actual":{"action":"GIVE","units":7.8},"check":"maximum bolus cap not on half unit","expected":{"action":"GIVE","units":7.5},"passed":false},{"actual":{"action":"GIVE","units":2.0},"check":"correction only control","expected":{"action":"GIVE","units":2.0},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"low glucose with meal is held\", \"actual\": {\"action\": \"HOLD\", \"units\": 0.0}, \"expected\": {\"action\": \"HOLD\", \"units\": 0.0}, \"passed\": true}, {\"check\": \"glucose exactly 70 is dosed\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"high glucose with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 8.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 8.5}, \"passed\": true}, {\"check\": \"below target with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"insulin on board exceeds correction\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"pen resolution rounds down\", \"actual\": {\"action\": \"GIVE\", \"units\": 5.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 5.5}, \"passed\": true}, {\"check\": \"maximum bolus cap not on half unit\", \"actual\": {\"action\": \"GIVE\", \"units\": 7.8}, \"expected\": {\"action\": \"GIVE\", \"units\": 7.5}, \"passed\": false}, {\"check\": \"correction only control\", \"actual\": {\"action\": \"GIVE\", \"units\": 2.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 2.0}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.51,"exit_code":0,"observations":[{"actual":{"action":"HOLD","units":0.0},"check":"low glucose with meal is held","expected":{"action":"HOLD","units":0.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"glucose exactly 70 is dosed","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":8.5},"check":"high glucose with insulin on board","expected":{"action":"GIVE","units":8.5},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"below target with insulin on board","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":4.0},"check":"insulin on board exceeds correction","expected":{"action":"GIVE","units":4.0},"passed":true},{"actual":{"action":"GIVE","units":5.5},"check":"pen resolution rounds down","expected":{"action":"GIVE","units":5.5},"passed":true},{"actual":{"action":"GIVE","units":7.5},"check":"maximum bolus cap not on half unit","expected":{"action":"GIVE","units":7.5},"passed":true},{"actual":{"action":"GIVE","units":2.0},"check":"correction only control","expected":{"action":"GIVE","units":2.0},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"low glucose with meal is held\", \"actual\": {\"action\": \"HOLD\", \"units\": 0.0}, \"expected\": {\"action\": \"HOLD\", \"units\": 0.0}, \"passed\": true}, {\"check\": \"glucose exactly 70 is dosed\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"high glucose with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 8.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 8.5}, \"passed\": true}, {\"check\": \"below target with insulin on board\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"insulin on board exceeds correction\", \"actual\": {\"action\": \"GIVE\", \"units\": 4.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 4.0}, \"passed\": true}, {\"check\": \"pen resolution rounds down\", \"actual\": {\"action\": \"GIVE\", \"units\": 5.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 5.5}, \"passed\": true}, {\"check\": \"maximum bolus cap not on half unit\", \"actual\": {\"action\": \"GIVE\", \"units\": 7.5}, \"expected\": {\"action\": \"GIVE\", \"units\": 7.5}, \"passed\": true}, {\"check\": \"correction only control\", \"actual\": {\"action\": \"GIVE\", \"units\": 2.0}, \"expected\": {\"action\": \"GIVE\", \"units\": 2.0}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}