{"abstract":"Fat grams fall short when protein takes a larger share.","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":"Dividing by p+f mixes the protein share into the carb-fat ratio.","family":"w2-recipe_scaling_and_nutrition-macro-split-carb-fat-ratio","id":"FA-97281","implementations":{"attempt":{"sha256":"f0c8b9ca43f022b875d431422c468cf4bc6498c255b9e68a19089a8128188be8","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, p + f) / 9)\n    carb_g = r(Fraction(rem - 9 * 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-fat ratio', [3000, 100, [20, 50, 30]], [160, 370, 98]],\n  ['repair check: carb-fat ratio', [2500, 118, [10, 60, 30]], [189, 290, 65]],\n  ['generated control 1', [3000, 50, [35, 35, 30]], [263, 262, 100]],\n  ['generated control 2', [1800, 83, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [1800, 91, [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-fat ratio', [2500, 120, [30, 40, 30]], [192, 249, 82]],\n  ['repair check: carb-fat ratio', [1500, 72, [40, 30, 30]], [150, 113, 50]],\n  ['generated control 1', [2200, 83, [30, 40, 29]], 'error: split'],\n  ['generated control 2', [2500, 100, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2000, 60, [20, 50, 30]], [100, 249, 67]]],\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-fat ratio', [2000, 72, [40, 30, 30]], [200, 149, 67]],\n  ['repair check: carb-fat ratio', [3000, 72, [20, 50, 30]], [150, 375, 100]],\n  ['generated control 1', [3000, 72, [20, 50, 25]], 'error: split'],\n  ['generated control 2', [2000, 72, [30, 40, 29]], 'error: split'],\n  ['generated control 3', [2500, 72, [30, 40, 30]], [188, 250, 83]]],\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-fat ratio', [3000, 83, [35, 35, 30]], [263, 262, 100]],\n  ['repair check: carb-fat ratio', [1500, 120, [25, 45, 30]], [192, 109, 33]],\n  ['generated control 1', [1800, 120, [35, 35, 30]], [192, 139, 53]],\n  ['generated control 2', [3000, 91, [40, 30, 30]], [300, 225, 100]],\n  ['generated control 3', [3000, 118, [30, 40, 30]], [225, 300, 100]]],\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-fat ratio', [1800, 83, [35, 35, 30]], [158, 157, 60]],\n  ['repair check: carb-fat ratio', [1800, 120, [30, 40, 30]], [192, 148, 49]],\n  ['generated control 1', [1800, 83, [15, 55, 30]], [133, 205, 50]],\n  ['generated control 2', [3000, 60, [20, 50, 25]], 'error: split'],\n  ['generated control 3', [2200, 100, [10, 60, 30]], [160, 260, 58]]]]\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":"1c754272c2ec460c40d67affb11d395aee7898ded36135d2b4ac50c48a55e7bf","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, 100) / 9)\n    carb_g = r(Fraction(rem - 9 * 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-fat ratio', [3000, 100, [20, 50, 30]], [160, 370, 98]],\n  ['repair check: carb-fat ratio', [2500, 118, [10, 60, 30]], [189, 290, 65]],\n  ['generated control 1', [3000, 50, [35, 35, 30]], [263, 262, 100]],\n  ['generated control 2', [1800, 83, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [1800, 91, [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-fat ratio', [2500, 120, [30, 40, 30]], [192, 249, 82]],\n  ['repair check: carb-fat ratio', [1500, 72, [40, 30, 30]], [150, 113, 50]],\n  ['generated control 1', [2200, 83, [30, 40, 29]], 'error: split'],\n  ['generated control 2', [2500, 100, [30, 40, 31]], 'error: split'],\n  ['generated control 3', [2000, 60, [20, 50, 30]], [100, 249, 67]]],\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-fat ratio', [2000, 72, [40, 30, 30]], [200, 149, 67]],\n  ['repair check: carb-fat ratio', [3000, 72, [20, 50, 30]], [150, 375, 100]],\n  ['generated control 1', [3000, 72, [20, 50, 25]], 'error: split'],\n  ['generated control 2', [2000, 72, [30, 40, 29]], 'error: split'],\n  ['generated control 3', [2500, 72, [30, 40, 30]], [188, 250, 83]]],\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-fat ratio', [3000, 83, [35, 35, 30]], [263, 262, 100]],\n  ['repair check: carb-fat ratio', [1500, 120, [25, 45, 30]], [192, 109, 33]],\n  ['generated control 1', [1800, 120, [35, 35, 30]], [192, 139, 53]],\n  ['generated control 2', [3000, 91, [40, 30, 30]], [300, 225, 100]],\n  ['generated control 3', [3000, 118, [30, 40, 30]], [225, 300, 100]]],\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-fat ratio', [1800, 83, [35, 35, 30]], [158, 157, 60]],\n  ['repair check: carb-fat ratio', [1800, 120, [30, 40, 30]], [192, 148, 49]],\n  ['generated control 1', [1800, 83, [15, 55, 30]], [133, 205, 50]],\n  ['generated control 2', [3000, 60, [20, 50, 25]], 'error: split'],\n  ['generated control 3', [2200, 100, [10, 60, 30]], [160, 260, 58]]]]\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-fat-ratio","generated_at":"2026-09-29T14:52:30.684573+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":"Fat's share of the remainder divides by 100 instead of by the carb+fat total.","sha256":"bb4632c429f9f21951683efcb9b05b8928c526b9f8942ba491b4f55e3a49689d","title":"Macronutrient target splitter: carb-fat ratio · 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":43.77,"exit_code":1,"observations":[{"actual":[150,175,78],"check":"balanced","expected":[150,199,67],"passed":false},{"actual":[192,62,54],"check":"protein floor binds","expected":[192,118,29],"passed":false},{"actual":"error: split","check":"bad split","expected":"error: split","passed":true},{"actual":[160,237,157],"check":"regression: carb-fat ratio","expected":[160,370,98],"passed":false},{"actual":[189,110,145],"check":"repair check: carb-fat ratio","expected":[189,290,65],"passed":false},{"actual":[263,262,100],"check":"generated control 1","expected":[263,262,100],"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, 175, 78], \"expected\": [150, 199, 67], \"passed\": false}, {\"check\": \"protein floor binds\", \"actual\": [192, 62, 54], \"expected\": [192, 118, 29], \"passed\": false}, {\"check\": \"bad split\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"regression: carb-fat ratio\", \"actual\": [160, 237, 157], \"expected\": [160, 370, 98], \"passed\": false}, {\"check\": \"repair check: carb-fat ratio\", \"actual\": [189, 110, 145], \"expected\": [189, 290, 65], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [263, 262, 100], \"expected\": [263, 262, 100], \"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":44.979,"exit_code":1,"observations":[{"actual":[150,244,47],"check":"balanced","expected":[150,199,67],"passed":false},{"actual":[192,129,24],"check":"protein floor binds","expected":[192,118,29],"passed":false},{"actual":"error: split","check":"bad split","expected":"error: split","passed":true},{"actual":[160,412,79],"check":"regression: carb-fat ratio","expected":[160,370,98],"passed":false},{"actual":[189,306,58],"check":"repair check: carb-fat ratio","expected":[189,290,65],"passed":false},{"actual":[263,341,65],"check":"generated control 1","expected":[263,262,100],"passed":false},{"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, 244, 47], \"expected\": [150, 199, 67], \"passed\": false}, {\"check\": \"protein floor binds\", \"actual\": [192, 129, 24], \"expected\": [192, 118, 29], \"passed\": false}, {\"check\": \"bad split\", \"actual\": \"error: split\", \"expected\": \"error: split\", \"passed\": true}, {\"check\": \"regression: carb-fat ratio\", \"actual\": [160, 412, 79], \"expected\": [160, 370, 98], \"passed\": false}, {\"check\": \"repair check: carb-fat ratio\", \"actual\": [189, 306, 58], \"expected\": [189, 290, 65], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [263, 341, 65], \"expected\": [263, 262, 100], \"passed\": false}, {\"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."}}