{"abstract":"Totals drift a few calories from the target because fat rounding is not absorbed.","category":"Recipe scaling and nutrition","checks":8,"contract":"split = [protein%, carb%, fat%] must sum to 100 else \"error: split\". protein_g = max(half-up kcal*p/400, ceiling(1.6*weight_kg)). Remaining kcal = kcal - 4*protein_g is divided between carb and fat in the ratio c:f; fat_g = half-up(rem*f/(c+f)/9); carb_g = half-up((rem - 9*fat_g)/4). Return [protein_g, carb_g, fat_g].","contract_signature":"kcal, weight_kg, split","evaluation_group":"w2-recipe_scaling_and_nutrition-macro-split","failed_approach":"Subtracting 4 kcal per fat gram leaves too much energy for carbs.","family":"w2-recipe_scaling_and_nutrition-macro-split-carb-from-remainder","id":"FA-97286","implementations":{"attempt":{"sha256":"7a744a3753cd1ef5f299b67eebc5c52e0be4583511a6d8f5d291f94e5611c8a9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(kcal, weight_kg, split):\n    p, c, f = split\n    if p + c + f != 100:\n        return 'error: split'\n    def r(x):\n        return math.floor(x + Fraction(1, 2))\n    protein_g = max(r(Fraction(kcal * p, 400)), math.ceil(Fraction(16, 10) * weight_kg))\n    rem = kcal - 4 * protein_g\n    fat_g = r(Fraction(rem * f, c + f) / 9)\n    carb_g = r(Fraction(rem - 4 * fat_g, 4))\n    return [protein_g, carb_g, fat_g]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['regression: carb from remainder', [2500, 83, [25, 45, 30]], [156, 282, 83]],\n  ['repair check: carb from remainder', [1800, 100, [40, 30, 30]], [180, 135, 60]],\n  ['generated control 1', [3000, 91, [30, 40, 29]], 'error: split'],\n  ['generated control 2', [1800, 118, [30, 40, 29]], 'error: split'],\n  ['generated control 3', [2000, 60, [20, 50, 25]], 'error: split']],\n [['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['regression: carb from remainder', [2000, 120, [15, 55, 30]], [192, 200, 48]],\n  ['repair check: carb from remainder', [2500, 60, [40, 30, 30]], [250, 188, 83]],\n  ['generated control 1', [2500, 120, [35, 35, 30]], [219, 219, 83]],\n  ['generated control 2', [2200, 60, [10, 60, 30]], [96, 303, 67]],\n  ['generated control 3', [2200, 120, [30, 40, 30]], [192, 205, 68]]],\n [['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['regression: carb from remainder', [2500, 60, [10, 60, 30]], [96, 354, 78]],\n  ['repair check: carb from remainder', [2500, 83, [35, 35, 30]], [219, 219, 83]],\n  ['generated control 1', [3000, 60, [15, 55, 30]], [113, 412, 100]],\n  ['generated control 2', [2500, 100, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2000, 118, [20, 50, 25]], 'error: split']],\n [['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['regression: carb from remainder', [2000, 72, [30, 40, 30]], [150, 199, 67]],\n  ['repair check: carb from remainder', [1500, 120, [40, 30, 30]], [192, 91, 41]],\n  ['generated control 1', [1800, 72, [15, 55, 30]], [116, 217, 52]],\n  ['generated control 2', [2000, 91, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2200, 100, [10, 60, 30]], [160, 260, 58]]],\n [['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['regression: carb from remainder', [1800, 100, [20, 50, 30]], [160, 182, 48]],\n  ['repair check: carb from remainder', [1500, 118, [20, 50, 30]], [189, 116, 31]],\n  ['generated control 1', [2200, 100, [20, 50, 25]], 'error: split'],\n  ['generated control 2', [3000, 91, [35, 35, 30]], [263, 262, 100]],\n  ['generated control 3', [2500, 72, [25, 45, 30]], [156, 282, 83]]]]\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":"0eaaa659ac9561d8a8f9abf6c255c63ee78d4ea8b0173b628c47434a2f150192","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(kcal, weight_kg, split):\n    p, c, f = split\n    if p + c + f != 100:\n        return 'error: split'\n    def r(x):\n        return math.floor(x + Fraction(1, 2))\n    protein_g = max(r(Fraction(kcal * p, 400)), math.ceil(Fraction(16, 10) * weight_kg))\n    rem = kcal - 4 * protein_g\n    fat_g = r(Fraction(rem * f, c + f) / 9)\n    carb_g = r(Fraction(rem * c, c + f) / 4)\n    return [protein_g, carb_g, fat_g]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['regression: carb from remainder', [2500, 83, [25, 45, 30]], [156, 282, 83]],\n  ['repair check: carb from remainder', [1800, 100, [40, 30, 30]], [180, 135, 60]],\n  ['generated control 1', [3000, 91, [30, 40, 29]], 'error: split'],\n  ['generated control 2', [1800, 118, [30, 40, 29]], 'error: split'],\n  ['generated control 3', [2000, 60, [20, 50, 25]], 'error: split']],\n [['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['regression: carb from remainder', [2000, 120, [15, 55, 30]], [192, 200, 48]],\n  ['repair check: carb from remainder', [2500, 60, [40, 30, 30]], [250, 188, 83]],\n  ['generated control 1', [2500, 120, [35, 35, 30]], [219, 219, 83]],\n  ['generated control 2', [2200, 60, [10, 60, 30]], [96, 303, 67]],\n  ['generated control 3', [2200, 120, [30, 40, 30]], [192, 205, 68]]],\n [['bad split', [2000, 70, [30, 40, 31]], 'error: split'],\n  ['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['regression: carb from remainder', [2500, 60, [10, 60, 30]], [96, 354, 78]],\n  ['repair check: carb from remainder', [2500, 83, [35, 35, 30]], [219, 219, 83]],\n  ['generated control 1', [3000, 60, [15, 55, 30]], [113, 412, 100]],\n  ['generated control 2', [2500, 100, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2000, 118, [20, 50, 25]], 'error: split']],\n [['split under 100', [2000, 70, [30, 40, 20]], 'error: split'],\n  ['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['regression: carb from remainder', [2000, 72, [30, 40, 30]], [150, 199, 67]],\n  ['repair check: carb from remainder', [1500, 120, [40, 30, 30]], [192, 91, 41]],\n  ['generated control 1', [1800, 72, [15, 55, 30]], [116, 217, 52]],\n  ['generated control 2', [2000, 91, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2200, 100, [10, 60, 30]], [160, 260, 58]]],\n [['fractional floor', [1200, 83, [20, 50, 30]], [133, 104, 28]],\n  ['balanced', [2000, 70, [30, 40, 30]], [150, 199, 67]],\n  ['protein floor binds', [1500, 120, [15, 55, 30]], [192, 118, 29]],\n  ['regression: carb from remainder', [1800, 100, [20, 50, 30]], [160, 182, 48]],\n  ['repair check: carb from remainder', [1500, 118, [20, 50, 30]], [189, 116, 31]],\n  ['generated control 1', [2200, 100, [20, 50, 25]], 'error: split'],\n  ['generated control 2', [3000, 91, [35, 35, 30]], [263, 262, 100]],\n  ['generated control 3', [2500, 72, [25, 45, 30]], [156, 282, 83]]]]\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 contract stated in full here; it is a bounded teaching model, not an authoritative reference or standards implementation. 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-recipe_scaling_and_nutrition-macro-split-carb-from-remainder","generated_at":"2026-09-29T14:52:30.723097+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Meal-plan generators turn calorie targets into gram targets with a protein floor by body weight.","root_cause":"Carbs are computed from the ratio independently rather than from energy left after rounded fat.","sha256":"181441ba20fbcd382b9571ebbf9033223ec3f5a6dd1fe27e1323280fc99a59c7","title":"Macronutrient target splitter: carb from remainder · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":45.482,"exit_code":1,"observations":[{"actual":[150,283,67],"check":"balanced","expected":[150,199,67],"passed":false},{"actual":[192,154,29],"check":"protein floor binds","expected":[192,118,29],"passed":false},{"actual":"error: split","check":"bad split","expected":"error: split","passed":true},{"actual":[156,386,83],"check":"regression: carb from remainder","expected":[156,282,83],"passed":false},{"actual":[180,210,60],"check":"repair check: carb from remainder","expected":[180,135,60],"passed":false},{"actual":"error: split","check":"generated control 1","expected":"error: split","passed":true},{"actual":"error: split","check":"generated control 2","expected":"error: split","passed":true},{"actual":"error: split","check":"generated control 3","expected":"error: split","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"balanced\", \"actual\": [150, 283, 67], \"expected\": [150, 199, 67], \"passed\": false}, {\"check\": \"protein floor binds\", \"actual\": [192, 154, 29], \"expected\": [192, 118, 29], \"passed\": false}, {\"check\": \"bad split\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"regression: carb from remainder\", \"actual\": [156, 386, 83], \"expected\": [156, 282, 83], \"passed\": false}, {\"check\": \"repair check: carb from remainder\", \"actual\": [180, 210, 60], \"expected\": [180, 135, 60], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.868,"exit_code":1,"observations":[{"actual":[150,200,67],"check":"balanced","expected":[150,199,67],"passed":false},{"actual":[192,118,29],"check":"protein floor binds","expected":[192,118,29],"passed":true},{"actual":"error: split","check":"bad split","expected":"error: split","passed":true},{"actual":[156,281,83],"check":"regression: carb from remainder","expected":[156,282,83],"passed":false},{"actual":[180,135,60],"check":"repair check: carb from remainder","expected":[180,135,60],"passed":true},{"actual":"error: split","check":"generated control 1","expected":"error: split","passed":true},{"actual":"error: split","check":"generated control 2","expected":"error: split","passed":true},{"actual":"error: split","check":"generated control 3","expected":"error: split","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"balanced\", \"actual\": [150, 200, 67], \"expected\": [150, 199, 67], \"passed\": false}, {\"check\": \"protein floor binds\", \"actual\": [192, 118, 29], \"expected\": [192, 118, 29], \"passed\": true}, {\"check\": \"bad split\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"regression: carb from remainder\", \"actual\": [156, 281, 83], \"expected\": [156, 282, 83], \"passed\": false}, {\"check\": \"repair check: carb from remainder\", \"actual\": [180, 135, 60], \"expected\": [180, 135, 60], \"passed\": true}, {\"check\": \"generated control 1\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}