FA-96876 / Recipe scaling and nutrition / Open access
Nutrition label rounding: calorie coarse band step · case 01
65 kcal prints as 65 instead of 70.
ROOT CAUSE
Above 50 kcal the value keeps the 5-calorie step instead of switching to the 10-calorie step.
VERIFIED REPAIR
Round calories above 50 to the nearest 10.
Unsuccessful approach: Starting the 10-calorie step only above 100 still prints 55-100 kcal in 5 steps.
Case contract
Round a panel dict to displayed strings (toy label rules, half-up): calories <5 -> 0, <=50 -> nearest 5, else nearest 10; fat g <0.5 -> 0, <5 -> nearest 0.5, else nearest 1; sodium mg <5 -> 0, <=140 -> nearest 5, else nearest 10; cholesterol mg <2 -> "0 mg", <5 -> "less than 5 mg", else nearest 5; carbs g <0.5 -> "0 g", <1 -> "less than 1 g", else nearest 1. Absent keys are omitted. Values print with %g formatting.
Why this case matters
Packaged food and meal-kit labels are generated from recipe nutrition totals with banded rounding rules that differ per nutrient.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(panel):
def near(x, step):
return math.floor(x / step + Fraction(1, 2)) * step
def show(v, unit):
t = format(float(v), 'g')
return t + ' ' + unit if unit else t
out = {}
if 'calories' in panel:
c = Fraction(str(panel['calories']))
out['calories'] = show(0 if c < 5 else near(c, 5) if c <= 50 else near(c, 5), '')
if 'fat' in panel:
x = Fraction(str(panel['fat']))
out['fat'] = show(0 if x < Fraction(1, 2) else near(x, Fraction(1, 2)) if x < 5 else near(x, 1), 'g')
if 'sodium' in panel:
x = Fraction(str(panel['sodium']))
out['sodium'] = show(0 if x < 5 else near(x, 5) if x <= 140 else near(x, 10), 'mg')
if 'cholesterol' in panel:
x = Fraction(str(panel['cholesterol']))
out['cholesterol'] = '0 mg' if x < 2 else 'less than 5 mg' if x < 5 else show(near(x, 5), 'mg')
if 'carbs' in panel:
x = Fraction(str(panel['carbs']))
out['carbs'] = '0 g' if x < Fraction(1, 2) else 'less than 1 g' if x < 1 else show(near(x, 1), 'g')
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['regression: calorie coarse band step',
[{'calories': 136.5, 'carbs': 0.9, 'cholesterol': 3, 'fat': 3.5, 'sodium': 10.5}],
{'calories': '140',
'carbs': 'less than 1 g',
'cholesterol': 'less than 5 mg',
'fat': '3.5 g',
'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 1.5, 'fat': 11, 'sodium': 7.5}],
{'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'}],
['generated control 1', [{'cholesterol': 7.5, 'fat': 15}], {'cholesterol': '10 mg', 'fat': '15 g'}],
['generated control 2', [{'calories': 43, 'fat': 2.75, 'sodium': 12.5}],
{'calories': '45', 'fat': '3 g', 'sodium': '15 mg'}],
['generated control 3', [{'calories': 351, 'fat': 4}], {'calories': '350', 'fat': '4 g'}]],
[['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['regression: calorie coarse band step',
[{'calories': 105, 'carbs': 30.4, 'cholesterol': 22.5, 'sodium': 12.5}],
{'calories': '110', 'carbs': '30 g', 'cholesterol': '25 mg', 'sodium': '15 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 12.5, 'cholesterol': 12, 'fat': 0.4}],
{'calories': '60', 'carbs': '13 g', 'cholesterol': '10 mg', 'fat': '0 g'}],
['generated control 1', [{'calories': 45.25, 'fat': 1.25, 'sodium': 7.5}],
{'calories': '45', 'fat': '1.5 g', 'sodium': '10 mg'}],
['generated control 2', [{'calories': 47.5, 'carbs': 12.5, 'cholesterol': 12, 'sodium': 7.5}],
{'calories': '50', 'carbs': '13 g', 'cholesterol': '10 mg', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'cholesterol': 4.9, 'fat': 12.25, 'sodium': 1.75}],
{'calories': '50', 'cholesterol': 'less than 5 mg', 'fat': '12 g', 'sodium': '0 mg'}]],
[['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['regression: calorie coarse band step', [{'calories': 105, 'fat': 1.25, 'sodium': 98.5}],
{'calories': '110', 'fat': '1.5 g', 'sodium': '100 mg'}],
['repair check: calorie coarse band step',
[{'calories': 55, 'cholesterol': 5, 'fat': 20.25, 'sodium': 1.75}],
{'calories': '60', 'cholesterol': '5 mg', 'fat': '20 g', 'sodium': '0 mg'}],
['generated control 1', [{'calories': 166, 'carbs': 30.4, 'fat': 18.25, 'sodium': 10.75}],
{'calories': '170', 'carbs': '30 g', 'fat': '18 g', 'sodium': '10 mg'}],
['generated control 2', [{'carbs': 30.4, 'cholesterol': 1.5, 'fat': 10.25}],
{'carbs': '30 g', 'cholesterol': '0 mg', 'fat': '10 g'}],
['generated control 3', [{'calories': 105, 'carbs': 1.5}], {'calories': '110', 'carbs': '2 g'}]],
[['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['regression: calorie coarse band step',
[{'calories': 54.75, 'carbs': 0.9, 'cholesterol': 4.9, 'sodium': 181.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'sodium': '180 mg'}],
['repair check: calorie coarse band step', [{'calories': 55.25, 'cholesterol': 1.5, 'fat': 1.25}],
{'calories': '60', 'cholesterol': '0 mg', 'fat': '1.5 g'}],
['generated control 1', [{'calories': 49.25, 'carbs': 0.9, 'cholesterol': 7.5, 'fat': 6, 'sodium': 171.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': '10 mg', 'fat': '6 g', 'sodium': '170 mg'}],
['generated control 2', [{'calories': 60, 'fat': 16.75, 'sodium': 8}],
{'calories': '60', 'fat': '17 g', 'sodium': '10 mg'}],
['generated control 3', [{'carbs': 1.5, 'fat': 5.25, 'sodium': 142.5}],
{'carbs': '2 g', 'fat': '5 g', 'sodium': '140 mg'}]],
[['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['regression: calorie coarse band step',
[{'calories': 105, 'cholesterol': 12, 'fat': 1.25, 'sodium': 10.5}],
{'calories': '110', 'cholesterol': '10 mg', 'fat': '1.5 g', 'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'fat': 2.5, 'sodium': 137.5}],
{'calories': '60', 'fat': '2.5 g', 'sodium': '140 mg'}],
['generated control 1', [{'fat': 2.75, 'sodium': 101.5}], {'fat': '3 g', 'sodium': '100 mg'}],
['generated control 2', [{'calories': 251.5, 'carbs': 12.5, 'fat': 4.75, 'sodium': 10.25}],
{'calories': '250', 'carbs': '13 g', 'fat': '5 g', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'carbs': 30.4, 'fat': 1.25, 'sodium': 4.25}],
{'calories': '50', 'carbs': '30 g', 'fat': '1.5 g', 'sodium': '0 mg'}]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| empty panel | {} | {} | Passed |
| insignificant calories | {'calories': '0', 'fat': '0 g'} | {'calories': '0', 'fat': '0 g'} | Passed |
| mid-band sodium | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | Passed |
| regression: calorie coarse band step | {'calories': '135', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | {'calories': '140', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | Failed |
| repair check: calorie coarse band step | {'calories': '55', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | {'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | Failed |
| generated control 1 | {'cholesterol': '10 mg', 'fat': '15 g'} | {'cholesterol': '10 mg', 'fat': '15 g'} | Passed |
| generated control 2 | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | Passed |
| generated control 3 | {'calories': '350', 'fat': '4 g'} | {'calories': '350', 'fat': '4 g'} | Passed |
SHA-256 / af5a25d0146de0266278d4f2e4abc367d2bf34fa3f7ed9c86914bb25c3bc8247
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(panel):
def near(x, step):
return math.floor(x / step + Fraction(1, 2)) * step
def show(v, unit):
t = format(float(v), 'g')
return t + ' ' + unit if unit else t
out = {}
if 'calories' in panel:
c = Fraction(str(panel['calories']))
out['calories'] = show(0 if c < 5 else near(c, 5) if c <= 50 else near(c, 10) if c > 100 else near(c, 5), '')
if 'fat' in panel:
x = Fraction(str(panel['fat']))
out['fat'] = show(0 if x < Fraction(1, 2) else near(x, Fraction(1, 2)) if x < 5 else near(x, 1), 'g')
if 'sodium' in panel:
x = Fraction(str(panel['sodium']))
out['sodium'] = show(0 if x < 5 else near(x, 5) if x <= 140 else near(x, 10), 'mg')
if 'cholesterol' in panel:
x = Fraction(str(panel['cholesterol']))
out['cholesterol'] = '0 mg' if x < 2 else 'less than 5 mg' if x < 5 else show(near(x, 5), 'mg')
if 'carbs' in panel:
x = Fraction(str(panel['carbs']))
out['carbs'] = '0 g' if x < Fraction(1, 2) else 'less than 1 g' if x < 1 else show(near(x, 1), 'g')
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['regression: calorie coarse band step',
[{'calories': 136.5, 'carbs': 0.9, 'cholesterol': 3, 'fat': 3.5, 'sodium': 10.5}],
{'calories': '140',
'carbs': 'less than 1 g',
'cholesterol': 'less than 5 mg',
'fat': '3.5 g',
'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 1.5, 'fat': 11, 'sodium': 7.5}],
{'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'}],
['generated control 1', [{'cholesterol': 7.5, 'fat': 15}], {'cholesterol': '10 mg', 'fat': '15 g'}],
['generated control 2', [{'calories': 43, 'fat': 2.75, 'sodium': 12.5}],
{'calories': '45', 'fat': '3 g', 'sodium': '15 mg'}],
['generated control 3', [{'calories': 351, 'fat': 4}], {'calories': '350', 'fat': '4 g'}]],
[['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['regression: calorie coarse band step',
[{'calories': 105, 'carbs': 30.4, 'cholesterol': 22.5, 'sodium': 12.5}],
{'calories': '110', 'carbs': '30 g', 'cholesterol': '25 mg', 'sodium': '15 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 12.5, 'cholesterol': 12, 'fat': 0.4}],
{'calories': '60', 'carbs': '13 g', 'cholesterol': '10 mg', 'fat': '0 g'}],
['generated control 1', [{'calories': 45.25, 'fat': 1.25, 'sodium': 7.5}],
{'calories': '45', 'fat': '1.5 g', 'sodium': '10 mg'}],
['generated control 2', [{'calories': 47.5, 'carbs': 12.5, 'cholesterol': 12, 'sodium': 7.5}],
{'calories': '50', 'carbs': '13 g', 'cholesterol': '10 mg', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'cholesterol': 4.9, 'fat': 12.25, 'sodium': 1.75}],
{'calories': '50', 'cholesterol': 'less than 5 mg', 'fat': '12 g', 'sodium': '0 mg'}]],
[['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['regression: calorie coarse band step', [{'calories': 105, 'fat': 1.25, 'sodium': 98.5}],
{'calories': '110', 'fat': '1.5 g', 'sodium': '100 mg'}],
['repair check: calorie coarse band step',
[{'calories': 55, 'cholesterol': 5, 'fat': 20.25, 'sodium': 1.75}],
{'calories': '60', 'cholesterol': '5 mg', 'fat': '20 g', 'sodium': '0 mg'}],
['generated control 1', [{'calories': 166, 'carbs': 30.4, 'fat': 18.25, 'sodium': 10.75}],
{'calories': '170', 'carbs': '30 g', 'fat': '18 g', 'sodium': '10 mg'}],
['generated control 2', [{'carbs': 30.4, 'cholesterol': 1.5, 'fat': 10.25}],
{'carbs': '30 g', 'cholesterol': '0 mg', 'fat': '10 g'}],
['generated control 3', [{'calories': 105, 'carbs': 1.5}], {'calories': '110', 'carbs': '2 g'}]],
[['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['regression: calorie coarse band step',
[{'calories': 54.75, 'carbs': 0.9, 'cholesterol': 4.9, 'sodium': 181.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'sodium': '180 mg'}],
['repair check: calorie coarse band step', [{'calories': 55.25, 'cholesterol': 1.5, 'fat': 1.25}],
{'calories': '60', 'cholesterol': '0 mg', 'fat': '1.5 g'}],
['generated control 1', [{'calories': 49.25, 'carbs': 0.9, 'cholesterol': 7.5, 'fat': 6, 'sodium': 171.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': '10 mg', 'fat': '6 g', 'sodium': '170 mg'}],
['generated control 2', [{'calories': 60, 'fat': 16.75, 'sodium': 8}],
{'calories': '60', 'fat': '17 g', 'sodium': '10 mg'}],
['generated control 3', [{'carbs': 1.5, 'fat': 5.25, 'sodium': 142.5}],
{'carbs': '2 g', 'fat': '5 g', 'sodium': '140 mg'}]],
[['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['regression: calorie coarse band step',
[{'calories': 105, 'cholesterol': 12, 'fat': 1.25, 'sodium': 10.5}],
{'calories': '110', 'cholesterol': '10 mg', 'fat': '1.5 g', 'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'fat': 2.5, 'sodium': 137.5}],
{'calories': '60', 'fat': '2.5 g', 'sodium': '140 mg'}],
['generated control 1', [{'fat': 2.75, 'sodium': 101.5}], {'fat': '3 g', 'sodium': '100 mg'}],
['generated control 2', [{'calories': 251.5, 'carbs': 12.5, 'fat': 4.75, 'sodium': 10.25}],
{'calories': '250', 'carbs': '13 g', 'fat': '5 g', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'carbs': 30.4, 'fat': 1.25, 'sodium': 4.25}],
{'calories': '50', 'carbs': '30 g', 'fat': '1.5 g', 'sodium': '0 mg'}]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| empty panel | {} | {} | Passed |
| insignificant calories | {'calories': '0', 'fat': '0 g'} | {'calories': '0', 'fat': '0 g'} | Passed |
| mid-band sodium | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | Passed |
| regression: calorie coarse band step | {'calories': '140', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | {'calories': '140', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | Passed |
| repair check: calorie coarse band step | {'calories': '55', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | {'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | Failed |
| generated control 1 | {'cholesterol': '10 mg', 'fat': '15 g'} | {'cholesterol': '10 mg', 'fat': '15 g'} | Passed |
| generated control 2 | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | Passed |
| generated control 3 | {'calories': '350', 'fat': '4 g'} | {'calories': '350', 'fat': '4 g'} | Passed |
SHA-256 / 9cab69aba784957dff9878b732581172ee8637af375ff2a66e5fec7874d2460d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(panel):
def near(x, step):
return math.floor(x / step + Fraction(1, 2)) * step
def show(v, unit):
t = format(float(v), 'g')
return t + ' ' + unit if unit else t
out = {}
if 'calories' in panel:
c = Fraction(str(panel['calories']))
out['calories'] = show(0 if c < 5 else near(c, 5) if c <= 50 else near(c, 10), '')
if 'fat' in panel:
x = Fraction(str(panel['fat']))
out['fat'] = show(0 if x < Fraction(1, 2) else near(x, Fraction(1, 2)) if x < 5 else near(x, 1), 'g')
if 'sodium' in panel:
x = Fraction(str(panel['sodium']))
out['sodium'] = show(0 if x < 5 else near(x, 5) if x <= 140 else near(x, 10), 'mg')
if 'cholesterol' in panel:
x = Fraction(str(panel['cholesterol']))
out['cholesterol'] = '0 mg' if x < 2 else 'less than 5 mg' if x < 5 else show(near(x, 5), 'mg')
if 'carbs' in panel:
x = Fraction(str(panel['carbs']))
out['carbs'] = '0 g' if x < Fraction(1, 2) else 'less than 1 g' if x < 1 else show(near(x, 1), 'g')
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['regression: calorie coarse band step',
[{'calories': 136.5, 'carbs': 0.9, 'cholesterol': 3, 'fat': 3.5, 'sodium': 10.5}],
{'calories': '140',
'carbs': 'less than 1 g',
'cholesterol': 'less than 5 mg',
'fat': '3.5 g',
'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 1.5, 'fat': 11, 'sodium': 7.5}],
{'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'}],
['generated control 1', [{'cholesterol': 7.5, 'fat': 15}], {'cholesterol': '10 mg', 'fat': '15 g'}],
['generated control 2', [{'calories': 43, 'fat': 2.75, 'sodium': 12.5}],
{'calories': '45', 'fat': '3 g', 'sodium': '15 mg'}],
['generated control 3', [{'calories': 351, 'fat': 4}], {'calories': '350', 'fat': '4 g'}]],
[['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['regression: calorie coarse band step',
[{'calories': 105, 'carbs': 30.4, 'cholesterol': 22.5, 'sodium': 12.5}],
{'calories': '110', 'carbs': '30 g', 'cholesterol': '25 mg', 'sodium': '15 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'carbs': 12.5, 'cholesterol': 12, 'fat': 0.4}],
{'calories': '60', 'carbs': '13 g', 'cholesterol': '10 mg', 'fat': '0 g'}],
['generated control 1', [{'calories': 45.25, 'fat': 1.25, 'sodium': 7.5}],
{'calories': '45', 'fat': '1.5 g', 'sodium': '10 mg'}],
['generated control 2', [{'calories': 47.5, 'carbs': 12.5, 'cholesterol': 12, 'sodium': 7.5}],
{'calories': '50', 'carbs': '13 g', 'cholesterol': '10 mg', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'cholesterol': 4.9, 'fat': 12.25, 'sodium': 1.75}],
{'calories': '50', 'cholesterol': 'less than 5 mg', 'fat': '12 g', 'sodium': '0 mg'}]],
[['mid-band sodium', [{'carbs': 0.9, 'sodium': 137.5}], {'carbs': 'less than 1 g', 'sodium': '140 mg'}],
['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['regression: calorie coarse band step', [{'calories': 105, 'fat': 1.25, 'sodium': 98.5}],
{'calories': '110', 'fat': '1.5 g', 'sodium': '100 mg'}],
['repair check: calorie coarse band step',
[{'calories': 55, 'cholesterol': 5, 'fat': 20.25, 'sodium': 1.75}],
{'calories': '60', 'cholesterol': '5 mg', 'fat': '20 g', 'sodium': '0 mg'}],
['generated control 1', [{'calories': 166, 'carbs': 30.4, 'fat': 18.25, 'sodium': 10.75}],
{'calories': '170', 'carbs': '30 g', 'fat': '18 g', 'sodium': '10 mg'}],
['generated control 2', [{'carbs': 30.4, 'cholesterol': 1.5, 'fat': 10.25}],
{'carbs': '30 g', 'cholesterol': '0 mg', 'fat': '10 g'}],
['generated control 3', [{'calories': 105, 'carbs': 1.5}], {'calories': '110', 'carbs': '2 g'}]],
[['large values', [{'calories': 245, 'cholesterol': 22.5, 'fat': 12.5, 'sodium': 455}],
{'calories': '250', 'cholesterol': '25 mg', 'fat': '13 g', 'sodium': '460 mg'}],
['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['regression: calorie coarse band step',
[{'calories': 54.75, 'carbs': 0.9, 'cholesterol': 4.9, 'sodium': 181.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'sodium': '180 mg'}],
['repair check: calorie coarse band step', [{'calories': 55.25, 'cholesterol': 1.5, 'fat': 1.25}],
{'calories': '60', 'cholesterol': '0 mg', 'fat': '1.5 g'}],
['generated control 1', [{'calories': 49.25, 'carbs': 0.9, 'cholesterol': 7.5, 'fat': 6, 'sodium': 171.5}],
{'calories': '50', 'carbs': 'less than 1 g', 'cholesterol': '10 mg', 'fat': '6 g', 'sodium': '170 mg'}],
['generated control 2', [{'calories': 60, 'fat': 16.75, 'sodium': 8}],
{'calories': '60', 'fat': '17 g', 'sodium': '10 mg'}],
['generated control 3', [{'carbs': 1.5, 'fat': 5.25, 'sodium': 142.5}],
{'carbs': '2 g', 'fat': '5 g', 'sodium': '140 mg'}]],
[['small cholesterol', [{'carbs': 12.5, 'cholesterol': 3}],
{'carbs': '13 g', 'cholesterol': 'less than 5 mg'}],
['empty panel', [{}], {}],
['insignificant calories', [{'calories': 4.9, 'fat': 0.4}], {'calories': '0', 'fat': '0 g'}],
['regression: calorie coarse band step',
[{'calories': 105, 'cholesterol': 12, 'fat': 1.25, 'sodium': 10.5}],
{'calories': '110', 'cholesterol': '10 mg', 'fat': '1.5 g', 'sodium': '10 mg'}],
['repair check: calorie coarse band step', [{'calories': 55, 'fat': 2.5, 'sodium': 137.5}],
{'calories': '60', 'fat': '2.5 g', 'sodium': '140 mg'}],
['generated control 1', [{'fat': 2.75, 'sodium': 101.5}], {'fat': '3 g', 'sodium': '100 mg'}],
['generated control 2', [{'calories': 251.5, 'carbs': 12.5, 'fat': 4.75, 'sodium': 10.25}],
{'calories': '250', 'carbs': '13 g', 'fat': '5 g', 'sodium': '10 mg'}],
['generated control 3', [{'calories': 47.5, 'carbs': 30.4, 'fat': 1.25, 'sodium': 4.25}],
{'calories': '50', 'carbs': '30 g', 'fat': '1.5 g', 'sodium': '0 mg'}]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| empty panel | {} | {} | Passed |
| insignificant calories | {'calories': '0', 'fat': '0 g'} | {'calories': '0', 'fat': '0 g'} | Passed |
| mid-band sodium | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | {'carbs': 'less than 1 g', 'sodium': '140 mg'} | Passed |
| regression: calorie coarse band step | {'calories': '140', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | {'calories': '140', 'carbs': 'less than 1 g', 'cholesterol': 'less than 5 mg', 'fat': '3.5 g', 'sodium': '10 mg'} | Passed |
| repair check: calorie coarse band step | {'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | {'calories': '60', 'carbs': '2 g', 'fat': '11 g', 'sodium': '10 mg'} | Passed |
| generated control 1 | {'cholesterol': '10 mg', 'fat': '15 g'} | {'cholesterol': '10 mg', 'fat': '15 g'} | Passed |
| generated control 2 | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | {'calories': '45', 'fat': '3 g', 'sodium': '15 mg'} | Passed |
| generated control 3 | {'calories': '350', 'fat': '4 g'} | {'calories': '350', 'fat': '4 g'} | Passed |
SHA-256 / 13a1dfdd913d5f3bef9c00ad0c7a1435e4c6785da20eef19b00ff4cdc3c5accc
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:52:26.663829+00:00.
Case digest / b92a351a86a7238b0c0f9afcf5f9fc617eb6b7dc85bee42629415083121ba8a7