{"abstract":"kJ disagrees with the exact energy because it is converted from the rounded kcal.","category":"Recipe scaling and nutrition","checks":8,"contract":"Gram amounts as strings. Total carbohydrate includes fiber and polyols; available carb = max(0, carb - fiber - polyol). kcal = 4*protein + 9*fat + 4*available + 2*fiber + 7*alcohol + 2.4*polyol. Return [kcal, kJ, fat_energy_pct]: kcal half-up integer of the exact energy, kJ half-up integer of exact kcal * 4.184, fat pct = half-up of 9*fat/exact kcal*100 (0 if energy is 0).","contract_signature":"protein, fat, carb, fiber, alcohol, polyol","evaluation_group":"w2-recipe_scaling_and_nutrition-atwater-energy","failed_approach":"Floor-dividing the rounded kcal compounds two rounding steps.","family":"w2-recipe_scaling_and_nutrition-atwater-energy-kilojoule-rounding-stage","id":"FA-96996","implementations":{"attempt":{"sha256":"46e1ce965e9690b29a2399d3c3c435adcedf6ff0f2d0e635ae7a42ffe868dc84","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(protein, fat, carb, fiber, alcohol, polyol):\n    p, fat, carb, fib, alc, poly = (Fraction(v) for v in (protein, fat, carb, fiber, alcohol, polyol))\n    avail = carb - fib - poly\n    avail = max(avail, Fraction(0))\n    exact = 4 * p + 9 * fat + 4 * avail + 2 * fib + 7 * alc + Fraction(12, 5) * poly\n    def r(x):\n        return math.floor(x + Fraction(1, 2))\n    kj = r(exact) * 4184 // 1000\n    pct_fat = r(9 * fat * 100 / exact) if exact else 0\n    return [r(exact), kj, pct_fat]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['regression: kilojoule rounding stage', ['17', '20', '13', '5', '0', '4'], [284, 1187, 63]],\n  ['repair check: kilojoule rounding stage', ['2', '11', '10', '2', '0', '4'], [137, 572, 72]],\n  ['generated control 1', ['32', '85/4', '53', '3', '0', '4'], [519, 2171, 37]],\n  ['generated control 2', ['39', '0', '20', '3', '14', '10'], [312, 1305, 0]],\n  ['generated control 3', ['31', '21/2', '31', '5', '14', '4'], [424, 1774, 22]]],\n [['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['regression: kilojoule rounding stage', ['36', '51/4', '19', '3', '0', '0'], [329, 1375, 35]],\n  ['repair check: kilojoule rounding stage', ['40', '5/2', '59', '8', '14', '0'], [501, 2094, 4]],\n  ['generated control 1', ['37', '11', '23', '1', '5', '0'], [372, 1556, 27]],\n  ['generated control 2', ['21', '2', '0', '2', '5', '4'], [151, 630, 12]],\n  ['generated control 3', ['8', '4', '18', '1', '14', '10'], [220, 920, 16]]],\n [['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['regression: kilojoule rounding stage', ['18', '13', '33', '1', '14', '4'], [411, 1718, 28]],\n  ['repair check: kilojoule rounding stage', ['34', '51/2', '31', '33', '5', '4'], [476, 1992, 48]],\n  ['generated control 1', ['23', '14', '45', '47', '5', '10'], [371, 1552, 34]],\n  ['generated control 2', ['31', '16', '4', '1', '0', '10'], [294, 1230, 49]],\n  ['generated control 3', ['21', '26', '0', '5', '0', '0'], [328, 1372, 71]]],\n [['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['regression: kilojoule rounding stage', ['2', '6', '0', '8', '0', '4'], [88, 367, 62]],\n  ['repair check: kilojoule rounding stage', ['20', '23', '57', '59', '0', '0'], [405, 1695, 51]],\n  ['generated control 1', ['31', '6', '40', '0', '14', '0'], [436, 1824, 12]],\n  ['generated control 2', ['24', '2', '46', '3', '0', '0'], [292, 1222, 6]],\n  ['generated control 3', ['8', '18', '15', '2', '0', '0'], [250, 1046, 65]]],\n [['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['regression: kilojoule rounding stage', ['26', '9', '59', '0', '5', '4'], [450, 1881, 18]],\n  ['repair check: kilojoule rounding stage', ['11', '23', '15', '8', '5', '0'], [330, 1381, 63]],\n  ['generated control 1', ['8', '6', '0', '1', '14', '10'], [210, 879, 26]],\n  ['generated control 2', ['36', '10', '7', '0', '5', '0'], [297, 1243, 30]],\n  ['generated control 3', ['4', '26', '7', '9', '14', '10'], [390, 1632, 60]]]]\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":"ce1ce982ffd46381ad0bd09202df1caa1d1085ec34619194f594897b0f292667","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(protein, fat, carb, fiber, alcohol, polyol):\n    p, fat, carb, fib, alc, poly = (Fraction(v) for v in (protein, fat, carb, fiber, alcohol, polyol))\n    avail = carb - fib - poly\n    avail = max(avail, Fraction(0))\n    exact = 4 * p + 9 * fat + 4 * avail + 2 * fib + 7 * alc + Fraction(12, 5) * poly\n    def r(x):\n        return math.floor(x + Fraction(1, 2))\n    kj = r(r(exact) * Fraction(4184, 1000))\n    pct_fat = r(9 * fat * 100 / exact) if exact else 0\n    return [r(exact), kj, pct_fat]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['regression: kilojoule rounding stage', ['17', '20', '13', '5', '0', '4'], [284, 1187, 63]],\n  ['repair check: kilojoule rounding stage', ['2', '11', '10', '2', '0', '4'], [137, 572, 72]],\n  ['generated control 1', ['32', '85/4', '53', '3', '0', '4'], [519, 2171, 37]],\n  ['generated control 2', ['39', '0', '20', '3', '14', '10'], [312, 1305, 0]],\n  ['generated control 3', ['31', '21/2', '31', '5', '14', '4'], [424, 1774, 22]]],\n [['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['regression: kilojoule rounding stage', ['36', '51/4', '19', '3', '0', '0'], [329, 1375, 35]],\n  ['repair check: kilojoule rounding stage', ['40', '5/2', '59', '8', '14', '0'], [501, 2094, 4]],\n  ['generated control 1', ['37', '11', '23', '1', '5', '0'], [372, 1556, 27]],\n  ['generated control 2', ['21', '2', '0', '2', '5', '4'], [151, 630, 12]],\n  ['generated control 3', ['8', '4', '18', '1', '14', '10'], [220, 920, 16]]],\n [['fiber heavier than carb', ['5', '1', '3', '6', '0', '0'], [41, 172, 22]],\n  ['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['regression: kilojoule rounding stage', ['18', '13', '33', '1', '14', '4'], [411, 1718, 28]],\n  ['repair check: kilojoule rounding stage', ['34', '51/2', '31', '33', '5', '4'], [476, 1992, 48]],\n  ['generated control 1', ['23', '14', '45', '47', '5', '10'], [371, 1552, 34]],\n  ['generated control 2', ['31', '16', '4', '1', '0', '10'], [294, 1230, 49]],\n  ['generated control 3', ['21', '26', '0', '5', '0', '0'], [328, 1372, 71]]],\n [['sugar-free candy', ['0', '5', '30', '1', '0', '20'], [131, 548, 34]],\n  ['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['regression: kilojoule rounding stage', ['2', '6', '0', '8', '0', '4'], [88, 367, 62]],\n  ['repair check: kilojoule rounding stage', ['20', '23', '57', '59', '0', '0'], [405, 1695, 51]],\n  ['generated control 1', ['31', '6', '40', '0', '14', '0'], [436, 1824, 12]],\n  ['generated control 2', ['24', '2', '46', '3', '0', '0'], [292, 1222, 6]],\n  ['generated control 3', ['8', '18', '15', '2', '0', '0'], [250, 1046, 65]]],\n [['cocktail', ['0', '0', '12', '0', '14', '0'], [146, 611, 0]],\n  ['all zero', ['0', '0', '0', '0', '0', '0'], [0, 0, 0]],\n  ['fat only', ['0', '10', '0', '0', '0', '0'], [90, 377, 100]],\n  ['regression: kilojoule rounding stage', ['26', '9', '59', '0', '5', '4'], [450, 1881, 18]],\n  ['repair check: kilojoule rounding stage', ['11', '23', '15', '8', '5', '0'], [330, 1381, 63]],\n  ['generated control 1', ['8', '6', '0', '1', '14', '10'], [210, 879, 26]],\n  ['generated control 2', ['36', '10', '7', '0', '5', '0'], [297, 1243, 30]],\n  ['generated control 3', ['4', '26', '7', '9', '14', '10'], [390, 1632, 60]]]]\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-atwater-energy-kilojoule-rounding-stage","generated_at":"2026-09-29T14:52:27.825014+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Recipe energy totals use factor systems where fiber and sugar alcohols are not full carbohydrate.","root_cause":"Kilojoules are computed from the already rounded kilocalories.","sha256":"691867887aab36e3edc2587736644f7d452603c62ebace24a61687d17a45c27b","title":"Atwater energy calculator: kilojoule rounding stage · 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.48,"exit_code":1,"observations":[{"actual":[0,0,0],"check":"all zero","expected":[0,0,0],"passed":true},{"actual":[90,376,100],"check":"fat only","expected":[90,377,100],"passed":false},{"actual":[41,171,22],"check":"fiber heavier than carb","expected":[41,172,22],"passed":false},{"actual":[284,1188,63],"check":"regression: kilojoule rounding stage","expected":[284,1187,63],"passed":false},{"actual":[137,573,72],"check":"repair check: kilojoule rounding stage","expected":[137,572,72],"passed":false},{"actual":[519,2171,37],"check":"generated control 1","expected":[519,2171,37],"passed":true},{"actual":[312,1305,0],"check":"generated control 2","expected":[312,1305,0],"passed":true},{"actual":[424,1774,22],"check":"generated control 3","expected":[424,1774,22],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"all zero\", \"actual\": [0, 0, 0], \"expected\": [0, 0, 0], \"passed\": true}, {\"check\": \"fat only\", \"actual\": [90, 376, 100], \"expected\": [90, 377, 100], \"passed\": false}, {\"check\": \"fiber heavier than carb\", \"actual\": [41, 171, 22], \"expected\": [41, 172, 22], \"passed\": false}, {\"check\": \"regression: kilojoule rounding stage\", \"actual\": [284, 1188, 63], \"expected\": [284, 1187, 63], \"passed\": false}, {\"check\": \"repair check: kilojoule rounding stage\", \"actual\": [137, 573, 72], \"expected\": [137, 572, 72], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [519, 2171, 37], \"expected\": [519, 2171, 37], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [312, 1305, 0], \"expected\": [312, 1305, 0], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [424, 1774, 22], \"expected\": [424, 1774, 22], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.135,"exit_code":1,"observations":[{"actual":[0,0,0],"check":"all zero","expected":[0,0,0],"passed":true},{"actual":[90,377,100],"check":"fat only","expected":[90,377,100],"passed":true},{"actual":[41,172,22],"check":"fiber heavier than carb","expected":[41,172,22],"passed":true},{"actual":[284,1188,63],"check":"regression: kilojoule rounding stage","expected":[284,1187,63],"passed":false},{"actual":[137,573,72],"check":"repair check: kilojoule rounding stage","expected":[137,572,72],"passed":false},{"actual":[519,2171,37],"check":"generated control 1","expected":[519,2171,37],"passed":true},{"actual":[312,1305,0],"check":"generated control 2","expected":[312,1305,0],"passed":true},{"actual":[424,1774,22],"check":"generated control 3","expected":[424,1774,22],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"all zero\", \"actual\": [0, 0, 0], \"expected\": [0, 0, 0], \"passed\": true}, {\"check\": \"fat only\", \"actual\": [90, 377, 100], \"expected\": [90, 377, 100], \"passed\": true}, {\"check\": \"fiber heavier than carb\", \"actual\": [41, 172, 22], \"expected\": [41, 172, 22], \"passed\": true}, {\"check\": \"regression: kilojoule rounding stage\", \"actual\": [284, 1188, 63], \"expected\": [284, 1187, 63], \"passed\": false}, {\"check\": \"repair check: kilojoule rounding stage\", \"actual\": [137, 573, 72], \"expected\": [137, 572, 72], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [519, 2171, 37], \"expected\": [519, 2171, 37], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [312, 1305, 0], \"expected\": [312, 1305, 0], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [424, 1774, 22], \"expected\": [424, 1774, 22], \"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."}}