FA-97226 / Recipe scaling and nutrition / Open access
Meal glycemic load: portion scaling · case 01
A 200 g portion counts the same as the 100 g reference.
ROOT CAUSE
Nutrient values are not scaled from the reference weight to the eaten weight.
VERIFIED REPAIR
Scale by eaten/per_grams.
Unsuccessful approach: Assuming every reference weight is 100 g breaks foods listed per 50 g.
Case contract
Rows [name, gi, carbs, fiber, grams_eaten, per_grams] where carbs and fiber are per per_grams. Available carb = (carbs-fiber)*eaten/per. Meal GI = sum(gi*avail)/sum(avail) half-up integer (None if no available carb). GL = sum(gi*avail)/100 half-up to 0.1. Class from the exact GL: <=10 low, <20 medium, else high.
Why this case matters
Diabetes-friendly meal planners estimate combined glycemic load from mixed foods.
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(foods):
tot = Fraction(0)
w = Fraction(0)
for name, gi, carbs, fiber, eaten, per in foods:
avail = (Fraction(str(carbs)) - Fraction(str(fiber))) * Fraction(1)
tot += avail
w += gi * avail
gi_meal = math.floor(w / tot + Fraction(1, 2)) if tot else None
gl = w / 100
cls = 'low' if gl <= 10 else 'medium' if gl < 20 else 'high'
return {'gi': gi_meal, 'gl': math.floor(gl * 10 + Fraction(1, 2)) / 10, 'class': cls}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling', [[['juice', 50, 10, 0, 150, 100], ['oats', 55, 60, 10, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 40.5}],
['repair check: portion scaling',
[[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 50, 50],
['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 60, 'gl': 94.8}],
['generated control 1', [[['bread', 75, 49, 2.7, 200, 100], ['oats', 55, 60, 10, 200, 100]]],
{'class': 'high', 'gi': 65, 'gl': 124.5}],
['generated control 2',
[[['juice', 50, 10, 0, 80, 100], ['oats', 55, 60, 10, 150, 100], ['lentils', 32, 20, 8, 50, 100],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 52, 'gl': 49.3}],
['generated control 3',
[[['oats', 55, 60, 10, 80, 100], ['lentils', 32, 20, 8, 200, 50], ['rice', 73, 28, 0.4, 30, 50]]],
{'class': 'high', 'gi': 47, 'gl': 49.4}]],
[['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['regression: portion scaling', [[['lentils', 32, 20, 8, 150, 100]]],
{'class': 'low', 'gi': 32, 'gl': 5.8}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 30, 50], ['apple', 36, 14, 2.4, 150, 50], ['juice', 50, 10, 0, 120, 100],
['rice', 73, 28, 0.4, 80, 50]]],
{'class': 'high', 'gi': 55, 'gl': 57.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 120, 100], ['bread', 75, 49, 2.7, 80, 100], ['oats', 55, 60, 10, 150, 100]]],
{'class': 'high', 'gi': 58, 'gl': 73.6}],
['generated control 2', [[['lentils', 32, 20, 8, 120, 100], ['apple', 36, 14, 2.4, 200, 100]]],
{'class': 'medium', 'gi': 34, 'gl': 13.0}],
['generated control 3', [[['oats', 55, 60, 10, 30, 100], ['lentils', 32, 20, 8, 30, 100]]],
{'class': 'low', 'gi': 51, 'gl': 9.4}]],
[['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['regression: portion scaling', [[['juice', 50, 10, 0, 30, 100], ['oats', 55, 60, 10, 200, 50]]],
{'class': 'high', 'gi': 55, 'gl': 111.5}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 50, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 120, 100],
['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 49, 'gl': 87.7}],
['generated control 1', [[['banana', 51, 23, 2.6, 50, 50]]], {'class': 'medium', 'gi': 51, 'gl': 10.4}],
['generated control 2', [[['bread', 75, 49, 2.7, 150, 100]]], {'class': 'high', 'gi': 75, 'gl': 52.1}],
['generated control 3',
[[['rice', 73, 28, 0.4, 50, 100], ['juice', 50, 10, 0, 50, 100], ['lentils', 32, 20, 8, 80, 100],
['bread', 75, 49, 2.7, 200, 100]]],
{'class': 'high', 'gi': 70, 'gl': 85.1}]],
[['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 80, 100], ['banana', 51, 23, 2.6, 50, 100],
['juice', 50, 10, 0, 150, 100]]],
{'class': 'high', 'gi': 57, 'gl': 31.1}],
['repair check: portion scaling',
[[['apple', 36, 14, 2.4, 50, 50], ['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 60, 'gl': 51.0}],
['generated control 1', [[['juice', 50, 10, 0, 120, 100]]], {'class': 'low', 'gi': 50, 'gl': 6.0}],
['generated control 2',
[[['juice', 50, 10, 0, 30, 100], ['apple', 36, 14, 2.4, 120, 50], ['bread', 75, 49, 2.7, 30, 100],
['banana', 51, 23, 2.6, 200, 100]]],
{'class': 'high', 'gi': 50, 'gl': 42.7}],
['generated control 3', [[['apple', 36, 14, 2.4, 50, 100]]], {'class': 'low', 'gi': 36, 'gl': 2.1}]],
[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 200, 50], ['juice', 50, 10, 0, 50, 50]]],
{'class': 'high', 'gi': 69, 'gl': 151.6}],
['repair check: portion scaling', [[['bread', 75, 49, 2.7, 120, 50], ['rice', 73, 28, 0.4, 50, 100]]],
{'class': 'high', 'gi': 75, 'gl': 93.4}],
['generated control 1', [[['rice', 73, 28, 0.4, 120, 100]]], {'class': 'high', 'gi': 73, 'gl': 24.2}],
['generated control 2',
[[['banana', 51, 23, 2.6, 120, 50], ['juice', 50, 10, 0, 50, 50], ['oats', 55, 60, 10, 200, 50],
['apple', 36, 14, 2.4, 150, 100]]],
{'class': 'high', 'gi': 53, 'gl': 146.2}],
['generated control 3',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 80, 100], ['bread', 75, 49, 2.7, 120, 100]]],
{'class': 'high', 'gi': 63, 'gl': 54.6}]]]
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 |
|---|---|---|---|
| single food | {'class': 'high', 'gi': 73, 'gl': 20.1} | {'class': 'high', 'gi': 73, 'gl': 30.2} | Failed |
| load exactly ten | {'class': 'low', 'gi': 50, 'gl': 5.0} | {'class': 'low', 'gi': 50, 'gl': 10.0} | Failed |
| no carbs | {'class': 'low', 'gi': None, 'gl': 0.0} | {'class': 'low', 'gi': None, 'gl': 0.0} | Passed |
| regression: portion scaling | {'class': 'high', 'gi': 54, 'gl': 32.5} | {'class': 'high', 'gi': 54, 'gl': 40.5} | Failed |
| repair check: portion scaling | {'class': 'high', 'gi': 63, 'gl': 86.2} | {'class': 'high', 'gi': 60, 'gl': 94.8} | Failed |
| generated control 1 | {'class': 'high', 'gi': 65, 'gl': 62.2} | {'class': 'high', 'gi': 65, 'gl': 124.5} | Failed |
| generated control 2 | {'class': 'high', 'gi': 48, 'gl': 40.5} | {'class': 'high', 'gi': 52, 'gl': 49.3} | Failed |
| generated control 3 | {'class': 'high', 'gi': 57, 'gl': 51.5} | {'class': 'high', 'gi': 47, 'gl': 49.4} | Failed |
SHA-256 / 54a3f42d9c87e56309e2865470a8ad4e605ce2d6badab2c22310d7cc73c32ef2
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(foods):
tot = Fraction(0)
w = Fraction(0)
for name, gi, carbs, fiber, eaten, per in foods:
avail = (Fraction(str(carbs)) - Fraction(str(fiber))) * Fraction(eaten, 100)
tot += avail
w += gi * avail
gi_meal = math.floor(w / tot + Fraction(1, 2)) if tot else None
gl = w / 100
cls = 'low' if gl <= 10 else 'medium' if gl < 20 else 'high'
return {'gi': gi_meal, 'gl': math.floor(gl * 10 + Fraction(1, 2)) / 10, 'class': cls}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling', [[['juice', 50, 10, 0, 150, 100], ['oats', 55, 60, 10, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 40.5}],
['repair check: portion scaling',
[[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 50, 50],
['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 60, 'gl': 94.8}],
['generated control 1', [[['bread', 75, 49, 2.7, 200, 100], ['oats', 55, 60, 10, 200, 100]]],
{'class': 'high', 'gi': 65, 'gl': 124.5}],
['generated control 2',
[[['juice', 50, 10, 0, 80, 100], ['oats', 55, 60, 10, 150, 100], ['lentils', 32, 20, 8, 50, 100],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 52, 'gl': 49.3}],
['generated control 3',
[[['oats', 55, 60, 10, 80, 100], ['lentils', 32, 20, 8, 200, 50], ['rice', 73, 28, 0.4, 30, 50]]],
{'class': 'high', 'gi': 47, 'gl': 49.4}]],
[['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['regression: portion scaling', [[['lentils', 32, 20, 8, 150, 100]]],
{'class': 'low', 'gi': 32, 'gl': 5.8}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 30, 50], ['apple', 36, 14, 2.4, 150, 50], ['juice', 50, 10, 0, 120, 100],
['rice', 73, 28, 0.4, 80, 50]]],
{'class': 'high', 'gi': 55, 'gl': 57.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 120, 100], ['bread', 75, 49, 2.7, 80, 100], ['oats', 55, 60, 10, 150, 100]]],
{'class': 'high', 'gi': 58, 'gl': 73.6}],
['generated control 2', [[['lentils', 32, 20, 8, 120, 100], ['apple', 36, 14, 2.4, 200, 100]]],
{'class': 'medium', 'gi': 34, 'gl': 13.0}],
['generated control 3', [[['oats', 55, 60, 10, 30, 100], ['lentils', 32, 20, 8, 30, 100]]],
{'class': 'low', 'gi': 51, 'gl': 9.4}]],
[['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['regression: portion scaling', [[['juice', 50, 10, 0, 30, 100], ['oats', 55, 60, 10, 200, 50]]],
{'class': 'high', 'gi': 55, 'gl': 111.5}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 50, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 120, 100],
['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 49, 'gl': 87.7}],
['generated control 1', [[['banana', 51, 23, 2.6, 50, 50]]], {'class': 'medium', 'gi': 51, 'gl': 10.4}],
['generated control 2', [[['bread', 75, 49, 2.7, 150, 100]]], {'class': 'high', 'gi': 75, 'gl': 52.1}],
['generated control 3',
[[['rice', 73, 28, 0.4, 50, 100], ['juice', 50, 10, 0, 50, 100], ['lentils', 32, 20, 8, 80, 100],
['bread', 75, 49, 2.7, 200, 100]]],
{'class': 'high', 'gi': 70, 'gl': 85.1}]],
[['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 80, 100], ['banana', 51, 23, 2.6, 50, 100],
['juice', 50, 10, 0, 150, 100]]],
{'class': 'high', 'gi': 57, 'gl': 31.1}],
['repair check: portion scaling',
[[['apple', 36, 14, 2.4, 50, 50], ['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 60, 'gl': 51.0}],
['generated control 1', [[['juice', 50, 10, 0, 120, 100]]], {'class': 'low', 'gi': 50, 'gl': 6.0}],
['generated control 2',
[[['juice', 50, 10, 0, 30, 100], ['apple', 36, 14, 2.4, 120, 50], ['bread', 75, 49, 2.7, 30, 100],
['banana', 51, 23, 2.6, 200, 100]]],
{'class': 'high', 'gi': 50, 'gl': 42.7}],
['generated control 3', [[['apple', 36, 14, 2.4, 50, 100]]], {'class': 'low', 'gi': 36, 'gl': 2.1}]],
[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 200, 50], ['juice', 50, 10, 0, 50, 50]]],
{'class': 'high', 'gi': 69, 'gl': 151.6}],
['repair check: portion scaling', [[['bread', 75, 49, 2.7, 120, 50], ['rice', 73, 28, 0.4, 50, 100]]],
{'class': 'high', 'gi': 75, 'gl': 93.4}],
['generated control 1', [[['rice', 73, 28, 0.4, 120, 100]]], {'class': 'high', 'gi': 73, 'gl': 24.2}],
['generated control 2',
[[['banana', 51, 23, 2.6, 120, 50], ['juice', 50, 10, 0, 50, 50], ['oats', 55, 60, 10, 200, 50],
['apple', 36, 14, 2.4, 150, 100]]],
{'class': 'high', 'gi': 53, 'gl': 146.2}],
['generated control 3',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 80, 100], ['bread', 75, 49, 2.7, 120, 100]]],
{'class': 'high', 'gi': 63, 'gl': 54.6}]]]
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 |
|---|---|---|---|
| single food | {'class': 'high', 'gi': 73, 'gl': 30.2} | {'class': 'high', 'gi': 73, 'gl': 30.2} | Passed |
| load exactly ten | {'class': 'low', 'gi': 50, 'gl': 10.0} | {'class': 'low', 'gi': 50, 'gl': 10.0} | Passed |
| no carbs | {'class': 'low', 'gi': None, 'gl': 0.0} | {'class': 'low', 'gi': None, 'gl': 0.0} | Passed |
| regression: portion scaling | {'class': 'high', 'gi': 54, 'gl': 40.5} | {'class': 'high', 'gi': 54, 'gl': 40.5} | Passed |
| repair check: portion scaling | {'class': 'high', 'gi': 59, 'gl': 83.6} | {'class': 'high', 'gi': 60, 'gl': 94.8} | Failed |
| generated control 1 | {'class': 'high', 'gi': 65, 'gl': 124.5} | {'class': 'high', 'gi': 65, 'gl': 124.5} | Passed |
| generated control 2 | {'class': 'high', 'gi': 52, 'gl': 49.3} | {'class': 'high', 'gi': 52, 'gl': 49.3} | Passed |
| generated control 3 | {'class': 'high', 'gi': 49, 'gl': 35.7} | {'class': 'high', 'gi': 47, 'gl': 49.4} | Failed |
SHA-256 / a2ede89f950a5fd43303dc169725359282a303c88633b780017dfc753abef65e
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(foods):
tot = Fraction(0)
w = Fraction(0)
for name, gi, carbs, fiber, eaten, per in foods:
avail = (Fraction(str(carbs)) - Fraction(str(fiber))) * Fraction(eaten, per)
tot += avail
w += gi * avail
gi_meal = math.floor(w / tot + Fraction(1, 2)) if tot else None
gl = w / 100
cls = 'low' if gl <= 10 else 'medium' if gl < 20 else 'high'
return {'gi': gi_meal, 'gl': math.floor(gl * 10 + Fraction(1, 2)) / 10, 'class': cls}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling', [[['juice', 50, 10, 0, 150, 100], ['oats', 55, 60, 10, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 40.5}],
['repair check: portion scaling',
[[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 50, 50],
['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 60, 'gl': 94.8}],
['generated control 1', [[['bread', 75, 49, 2.7, 200, 100], ['oats', 55, 60, 10, 200, 100]]],
{'class': 'high', 'gi': 65, 'gl': 124.5}],
['generated control 2',
[[['juice', 50, 10, 0, 80, 100], ['oats', 55, 60, 10, 150, 100], ['lentils', 32, 20, 8, 50, 100],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 52, 'gl': 49.3}],
['generated control 3',
[[['oats', 55, 60, 10, 80, 100], ['lentils', 32, 20, 8, 200, 50], ['rice', 73, 28, 0.4, 30, 50]]],
{'class': 'high', 'gi': 47, 'gl': 49.4}]],
[['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['regression: portion scaling', [[['lentils', 32, 20, 8, 150, 100]]],
{'class': 'low', 'gi': 32, 'gl': 5.8}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 30, 50], ['apple', 36, 14, 2.4, 150, 50], ['juice', 50, 10, 0, 120, 100],
['rice', 73, 28, 0.4, 80, 50]]],
{'class': 'high', 'gi': 55, 'gl': 57.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 120, 100], ['bread', 75, 49, 2.7, 80, 100], ['oats', 55, 60, 10, 150, 100]]],
{'class': 'high', 'gi': 58, 'gl': 73.6}],
['generated control 2', [[['lentils', 32, 20, 8, 120, 100], ['apple', 36, 14, 2.4, 200, 100]]],
{'class': 'medium', 'gi': 34, 'gl': 13.0}],
['generated control 3', [[['oats', 55, 60, 10, 30, 100], ['lentils', 32, 20, 8, 30, 100]]],
{'class': 'low', 'gi': 51, 'gl': 9.4}]],
[['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['regression: portion scaling', [[['juice', 50, 10, 0, 30, 100], ['oats', 55, 60, 10, 200, 50]]],
{'class': 'high', 'gi': 55, 'gl': 111.5}],
['repair check: portion scaling',
[[['banana', 51, 23, 2.6, 50, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 120, 100],
['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 49, 'gl': 87.7}],
['generated control 1', [[['banana', 51, 23, 2.6, 50, 50]]], {'class': 'medium', 'gi': 51, 'gl': 10.4}],
['generated control 2', [[['bread', 75, 49, 2.7, 150, 100]]], {'class': 'high', 'gi': 75, 'gl': 52.1}],
['generated control 3',
[[['rice', 73, 28, 0.4, 50, 100], ['juice', 50, 10, 0, 50, 100], ['lentils', 32, 20, 8, 80, 100],
['bread', 75, 49, 2.7, 200, 100]]],
{'class': 'high', 'gi': 70, 'gl': 85.1}]],
[['mixed meal', [[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 50, 100]]],
{'class': 'high', 'gi': 53, 'gl': 25.0}],
['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 30, 50], ['rice', 73, 28, 0.4, 80, 100], ['banana', 51, 23, 2.6, 50, 100],
['juice', 50, 10, 0, 150, 100]]],
{'class': 'high', 'gi': 57, 'gl': 31.1}],
['repair check: portion scaling',
[[['apple', 36, 14, 2.4, 50, 50], ['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 60, 'gl': 51.0}],
['generated control 1', [[['juice', 50, 10, 0, 120, 100]]], {'class': 'low', 'gi': 50, 'gl': 6.0}],
['generated control 2',
[[['juice', 50, 10, 0, 30, 100], ['apple', 36, 14, 2.4, 120, 50], ['bread', 75, 49, 2.7, 30, 100],
['banana', 51, 23, 2.6, 200, 100]]],
{'class': 'high', 'gi': 50, 'gl': 42.7}],
['generated control 3', [[['apple', 36, 14, 2.4, 50, 100]]], {'class': 'low', 'gi': 36, 'gl': 2.1}]],
[['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
['load exactly ten', [[['juice', 50, 10, 0, 200, 100]]], {'class': 'low', 'gi': 50, 'gl': 10.0}],
['no carbs', [[['egg', 0, 0, 0, 50, 100]]], {'class': 'low', 'gi': None, 'gl': 0.0}],
['regression: portion scaling',
[[['lentils', 32, 20, 8, 200, 100], ['bread', 75, 49, 2.7, 200, 50], ['juice', 50, 10, 0, 50, 50]]],
{'class': 'high', 'gi': 69, 'gl': 151.6}],
['repair check: portion scaling', [[['bread', 75, 49, 2.7, 120, 50], ['rice', 73, 28, 0.4, 50, 100]]],
{'class': 'high', 'gi': 75, 'gl': 93.4}],
['generated control 1', [[['rice', 73, 28, 0.4, 120, 100]]], {'class': 'high', 'gi': 73, 'gl': 24.2}],
['generated control 2',
[[['banana', 51, 23, 2.6, 120, 50], ['juice', 50, 10, 0, 50, 50], ['oats', 55, 60, 10, 200, 50],
['apple', 36, 14, 2.4, 150, 100]]],
{'class': 'high', 'gi': 53, 'gl': 146.2}],
['generated control 3',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 80, 100], ['bread', 75, 49, 2.7, 120, 100]]],
{'class': 'high', 'gi': 63, 'gl': 54.6}]]]
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 |
|---|---|---|---|
| single food | {'class': 'high', 'gi': 73, 'gl': 30.2} | {'class': 'high', 'gi': 73, 'gl': 30.2} | Passed |
| load exactly ten | {'class': 'low', 'gi': 50, 'gl': 10.0} | {'class': 'low', 'gi': 50, 'gl': 10.0} | Passed |
| no carbs | {'class': 'low', 'gi': None, 'gl': 0.0} | {'class': 'low', 'gi': None, 'gl': 0.0} | Passed |
| regression: portion scaling | {'class': 'high', 'gi': 54, 'gl': 40.5} | {'class': 'high', 'gi': 54, 'gl': 40.5} | Passed |
| repair check: portion scaling | {'class': 'high', 'gi': 60, 'gl': 94.8} | {'class': 'high', 'gi': 60, 'gl': 94.8} | Passed |
| generated control 1 | {'class': 'high', 'gi': 65, 'gl': 124.5} | {'class': 'high', 'gi': 65, 'gl': 124.5} | Passed |
| generated control 2 | {'class': 'high', 'gi': 52, 'gl': 49.3} | {'class': 'high', 'gi': 52, 'gl': 49.3} | Passed |
| generated control 3 | {'class': 'high', 'gi': 47, 'gl': 49.4} | {'class': 'high', 'gi': 47, 'gl': 49.4} | Passed |
SHA-256 / 0bb65c030a347f3d771b4108f552d2c36d7c513fe924d292a7c5d504da82ce3f
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:30.073736+00:00.
Case digest / aeeca88a7dd0dac8f47cf16576f67f66cacc894a619c346f7b9bec6d778b59d7