FA-97236 / Recipe scaling and nutrition / Open access
Meal glycemic load: class from exact load · case 01
A meal with a glycemic load of exactly 10 is called medium.
ROOT CAUSE
The low class excludes its upper bound of 10.
VERIFIED REPAIR
Classify exact loads up to and including 10 as low.
Unsuccessful approach: Classifying on the rounded load calls 10.03 low.
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(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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1', [[['rice', 73, 28, 0.4, 150, 100], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 68, 'gl': 38.5}],
['generated control 2',
[[['oats', 55, 60, 10, 50, 100], ['apple', 36, 14, 2.4, 150, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 45, 'gl': 21.9}],
['generated control 3', [[['lentils', 32, 20, 8, 30, 100]]], {'class': 'low', 'gi': 32, 'gl': 1.2}],
['generated control 4',
[[['banana', 51, 23, 2.6, 120, 100], ['apple', 36, 14, 2.4, 30, 50], ['juice', 50, 10, 0, 50, 100]]],
{'class': 'medium', 'gi': 48, 'gl': 17.5}]],
[['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}],
['repair check: class from exact load', [[['rice', 73, 28, 0.4, 30, 100], ['juice', 50, 10, 0, 80, 100]]],
{'class': 'medium', 'gi': 62, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 30, 100], ['bread', 75, 49, 2.7, 30, 100], ['apple', 36, 14, 2.4, 80, 50],
['lentils', 32, 20, 8, 30, 100]]],
{'class': 'medium', 'gi': 51, 'gl': 19.8}],
['generated control 2', [[['bread', 75, 49, 2.7, 30, 100], ['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 44, 'gl': 21.9}],
['generated control 3',
[[['lentils', 32, 20, 8, 80, 50], ['juice', 50, 10, 0, 150, 50], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 46, 'gl': 29.4}],
['generated control 4',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 50, 50], ['rice', 73, 28, 0.4, 150, 100],
['juice', 50, 10, 0, 30, 100]]],
{'class': 'high', 'gi': 59, 'gl': 46.7}]],
[['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: class from exact load', [[['juice', 50, 10, 0, 200, 100]]],
{'class': 'low', 'gi': 50, 'gl': 10.0}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 50, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 200, 50],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 47, 'gl': 32.3}],
['generated control 2', [[['lentils', 32, 20, 8, 150, 50]]], {'class': 'medium', 'gi': 32, 'gl': 11.5}],
['generated control 3',
[[['bread', 75, 49, 2.7, 30, 100], ['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 80, 100],
['oats', 55, 60, 10, 50, 100]]],
{'class': 'high', 'gi': 65, 'gl': 42.8}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 200, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 68, 'gl': 44.7}],
['generated control 2',
[[['juice', 50, 10, 0, 50, 50], ['banana', 51, 23, 2.6, 150, 100], ['lentils', 32, 20, 8, 80, 100],
['apple', 36, 14, 2.4, 120, 100]]],
{'class': 'high', 'gi': 45, 'gl': 28.7}],
['generated control 3',
[[['rice', 73, 28, 0.4, 150, 100], ['bread', 75, 49, 2.7, 150, 50], ['banana', 51, 23, 2.6, 30, 50],
['oats', 55, 60, 10, 150, 50]]],
{'class': 'high', 'gi': 65, 'gl': 223.1}],
['generated control 4',
[[['oats', 55, 60, 10, 150, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 55.6}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 120, 100], ['bread', 75, 49, 2.7, 150, 100], ['oats', 55, 60, 10, 120, 50],
['banana', 51, 23, 2.6, 30, 50]]],
{'class': 'high', 'gi': 61, 'gl': 130.3}],
['generated control 2',
[[['juice', 50, 10, 0, 200, 50], ['apple', 36, 14, 2.4, 120, 100], ['oats', 55, 60, 10, 200, 100],
['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 52, 'gl': 96.7}],
['generated control 3', [[['juice', 50, 10, 0, 80, 100], ['banana', 51, 23, 2.6, 30, 100]]],
{'class': 'low', 'gi': 50, 'gl': 7.1}],
['generated control 4', [[['bread', 75, 49, 2.7, 50, 100], ['apple', 36, 14, 2.4, 80, 100]]],
{'class': 'high', 'gi': 64, 'gl': 20.7}]]]
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': 'medium', 'gi': 50, 'gl': 10.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 |
| repair check: class from exact load | {'class': 'medium', 'gi': 36, 'gl': 10.0} | {'class': 'medium', 'gi': 36, 'gl': 10.0} | Passed |
| generated control 1 | {'class': 'high', 'gi': 68, 'gl': 38.5} | {'class': 'high', 'gi': 68, 'gl': 38.5} | Passed |
| generated control 2 | {'class': 'high', 'gi': 45, 'gl': 21.9} | {'class': 'high', 'gi': 45, 'gl': 21.9} | Passed |
| generated control 3 | {'class': 'low', 'gi': 32, 'gl': 1.2} | {'class': 'low', 'gi': 32, 'gl': 1.2} | Passed |
| generated control 4 | {'class': 'medium', 'gi': 48, 'gl': 17.5} | {'class': 'medium', 'gi': 48, 'gl': 17.5} | Passed |
SHA-256 / ed002252224813fcd822eb4053cc4174c9af57ae1ca792507789803f4b2919f0
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, 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 math.floor(gl * 10 + Fraction(1, 2)) / 10 <= 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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1', [[['rice', 73, 28, 0.4, 150, 100], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 68, 'gl': 38.5}],
['generated control 2',
[[['oats', 55, 60, 10, 50, 100], ['apple', 36, 14, 2.4, 150, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 45, 'gl': 21.9}],
['generated control 3', [[['lentils', 32, 20, 8, 30, 100]]], {'class': 'low', 'gi': 32, 'gl': 1.2}],
['generated control 4',
[[['banana', 51, 23, 2.6, 120, 100], ['apple', 36, 14, 2.4, 30, 50], ['juice', 50, 10, 0, 50, 100]]],
{'class': 'medium', 'gi': 48, 'gl': 17.5}]],
[['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}],
['repair check: class from exact load', [[['rice', 73, 28, 0.4, 30, 100], ['juice', 50, 10, 0, 80, 100]]],
{'class': 'medium', 'gi': 62, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 30, 100], ['bread', 75, 49, 2.7, 30, 100], ['apple', 36, 14, 2.4, 80, 50],
['lentils', 32, 20, 8, 30, 100]]],
{'class': 'medium', 'gi': 51, 'gl': 19.8}],
['generated control 2', [[['bread', 75, 49, 2.7, 30, 100], ['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 44, 'gl': 21.9}],
['generated control 3',
[[['lentils', 32, 20, 8, 80, 50], ['juice', 50, 10, 0, 150, 50], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 46, 'gl': 29.4}],
['generated control 4',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 50, 50], ['rice', 73, 28, 0.4, 150, 100],
['juice', 50, 10, 0, 30, 100]]],
{'class': 'high', 'gi': 59, 'gl': 46.7}]],
[['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: class from exact load', [[['juice', 50, 10, 0, 200, 100]]],
{'class': 'low', 'gi': 50, 'gl': 10.0}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 50, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 200, 50],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 47, 'gl': 32.3}],
['generated control 2', [[['lentils', 32, 20, 8, 150, 50]]], {'class': 'medium', 'gi': 32, 'gl': 11.5}],
['generated control 3',
[[['bread', 75, 49, 2.7, 30, 100], ['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 80, 100],
['oats', 55, 60, 10, 50, 100]]],
{'class': 'high', 'gi': 65, 'gl': 42.8}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 200, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 68, 'gl': 44.7}],
['generated control 2',
[[['juice', 50, 10, 0, 50, 50], ['banana', 51, 23, 2.6, 150, 100], ['lentils', 32, 20, 8, 80, 100],
['apple', 36, 14, 2.4, 120, 100]]],
{'class': 'high', 'gi': 45, 'gl': 28.7}],
['generated control 3',
[[['rice', 73, 28, 0.4, 150, 100], ['bread', 75, 49, 2.7, 150, 50], ['banana', 51, 23, 2.6, 30, 50],
['oats', 55, 60, 10, 150, 50]]],
{'class': 'high', 'gi': 65, 'gl': 223.1}],
['generated control 4',
[[['oats', 55, 60, 10, 150, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 55.6}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 120, 100], ['bread', 75, 49, 2.7, 150, 100], ['oats', 55, 60, 10, 120, 50],
['banana', 51, 23, 2.6, 30, 50]]],
{'class': 'high', 'gi': 61, 'gl': 130.3}],
['generated control 2',
[[['juice', 50, 10, 0, 200, 50], ['apple', 36, 14, 2.4, 120, 100], ['oats', 55, 60, 10, 200, 100],
['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 52, 'gl': 96.7}],
['generated control 3', [[['juice', 50, 10, 0, 80, 100], ['banana', 51, 23, 2.6, 30, 100]]],
{'class': 'low', 'gi': 50, 'gl': 7.1}],
['generated control 4', [[['bread', 75, 49, 2.7, 50, 100], ['apple', 36, 14, 2.4, 80, 100]]],
{'class': 'high', 'gi': 64, 'gl': 20.7}]]]
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 |
| repair check: class from exact load | {'class': 'low', 'gi': 36, 'gl': 10.0} | {'class': 'medium', 'gi': 36, 'gl': 10.0} | Failed |
| generated control 1 | {'class': 'high', 'gi': 68, 'gl': 38.5} | {'class': 'high', 'gi': 68, 'gl': 38.5} | Passed |
| generated control 2 | {'class': 'high', 'gi': 45, 'gl': 21.9} | {'class': 'high', 'gi': 45, 'gl': 21.9} | Passed |
| generated control 3 | {'class': 'low', 'gi': 32, 'gl': 1.2} | {'class': 'low', 'gi': 32, 'gl': 1.2} | Passed |
| generated control 4 | {'class': 'medium', 'gi': 48, 'gl': 17.5} | {'class': 'medium', 'gi': 48, 'gl': 17.5} | Passed |
SHA-256 / 308a6cbd2d12f79dcf6aa3b583c68e086489a1c8aaba78d1dc2ba9dc96a9631b
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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1', [[['rice', 73, 28, 0.4, 150, 100], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 68, 'gl': 38.5}],
['generated control 2',
[[['oats', 55, 60, 10, 50, 100], ['apple', 36, 14, 2.4, 150, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 45, 'gl': 21.9}],
['generated control 3', [[['lentils', 32, 20, 8, 30, 100]]], {'class': 'low', 'gi': 32, 'gl': 1.2}],
['generated control 4',
[[['banana', 51, 23, 2.6, 120, 100], ['apple', 36, 14, 2.4, 30, 50], ['juice', 50, 10, 0, 50, 100]]],
{'class': 'medium', 'gi': 48, 'gl': 17.5}]],
[['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}],
['repair check: class from exact load', [[['rice', 73, 28, 0.4, 30, 100], ['juice', 50, 10, 0, 80, 100]]],
{'class': 'medium', 'gi': 62, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 30, 100], ['bread', 75, 49, 2.7, 30, 100], ['apple', 36, 14, 2.4, 80, 50],
['lentils', 32, 20, 8, 30, 100]]],
{'class': 'medium', 'gi': 51, 'gl': 19.8}],
['generated control 2', [[['bread', 75, 49, 2.7, 30, 100], ['lentils', 32, 20, 8, 150, 50]]],
{'class': 'high', 'gi': 44, 'gl': 21.9}],
['generated control 3',
[[['lentils', 32, 20, 8, 80, 50], ['juice', 50, 10, 0, 150, 50], ['oats', 55, 60, 10, 30, 100]]],
{'class': 'high', 'gi': 46, 'gl': 29.4}],
['generated control 4',
[[['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 50, 50], ['rice', 73, 28, 0.4, 150, 100],
['juice', 50, 10, 0, 30, 100]]],
{'class': 'high', 'gi': 59, 'gl': 46.7}]],
[['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: class from exact load', [[['juice', 50, 10, 0, 200, 100]]],
{'class': 'low', 'gi': 50, 'gl': 10.0}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['lentils', 32, 20, 8, 50, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 200, 50],
['apple', 36, 14, 2.4, 50, 100]]],
{'class': 'high', 'gi': 47, 'gl': 32.3}],
['generated control 2', [[['lentils', 32, 20, 8, 150, 50]]], {'class': 'medium', 'gi': 32, 'gl': 11.5}],
['generated control 3',
[[['bread', 75, 49, 2.7, 30, 100], ['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 80, 100],
['oats', 55, 60, 10, 50, 100]]],
{'class': 'high', 'gi': 65, 'gl': 42.8}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 50, 100], ['rice', 73, 28, 0.4, 200, 100], ['lentils', 32, 20, 8, 50, 100]]],
{'class': 'high', 'gi': 68, 'gl': 44.7}],
['generated control 2',
[[['juice', 50, 10, 0, 50, 50], ['banana', 51, 23, 2.6, 150, 100], ['lentils', 32, 20, 8, 80, 100],
['apple', 36, 14, 2.4, 120, 100]]],
{'class': 'high', 'gi': 45, 'gl': 28.7}],
['generated control 3',
[[['rice', 73, 28, 0.4, 150, 100], ['bread', 75, 49, 2.7, 150, 50], ['banana', 51, 23, 2.6, 30, 50],
['oats', 55, 60, 10, 150, 50]]],
{'class': 'high', 'gi': 65, 'gl': 223.1}],
['generated control 4',
[[['oats', 55, 60, 10, 150, 100], ['banana', 51, 23, 2.6, 80, 100], ['juice', 50, 10, 0, 120, 100]]],
{'class': 'high', 'gi': 54, 'gl': 55.6}]],
[['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}],
['repair check: class from exact load', [[['apple', 36, 14, 2.4, 120, 50]]],
{'class': 'medium', 'gi': 36, 'gl': 10.0}],
['generated control 1',
[[['juice', 50, 10, 0, 120, 100], ['bread', 75, 49, 2.7, 150, 100], ['oats', 55, 60, 10, 120, 50],
['banana', 51, 23, 2.6, 30, 50]]],
{'class': 'high', 'gi': 61, 'gl': 130.3}],
['generated control 2',
[[['juice', 50, 10, 0, 200, 50], ['apple', 36, 14, 2.4, 120, 100], ['oats', 55, 60, 10, 200, 100],
['banana', 51, 23, 2.6, 80, 50]]],
{'class': 'high', 'gi': 52, 'gl': 96.7}],
['generated control 3', [[['juice', 50, 10, 0, 80, 100], ['banana', 51, 23, 2.6, 30, 100]]],
{'class': 'low', 'gi': 50, 'gl': 7.1}],
['generated control 4', [[['bread', 75, 49, 2.7, 50, 100], ['apple', 36, 14, 2.4, 80, 100]]],
{'class': 'high', 'gi': 64, 'gl': 20.7}]]]
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 |
| repair check: class from exact load | {'class': 'medium', 'gi': 36, 'gl': 10.0} | {'class': 'medium', 'gi': 36, 'gl': 10.0} | Passed |
| generated control 1 | {'class': 'high', 'gi': 68, 'gl': 38.5} | {'class': 'high', 'gi': 68, 'gl': 38.5} | Passed |
| generated control 2 | {'class': 'high', 'gi': 45, 'gl': 21.9} | {'class': 'high', 'gi': 45, 'gl': 21.9} | Passed |
| generated control 3 | {'class': 'low', 'gi': 32, 'gl': 1.2} | {'class': 'low', 'gi': 32, 'gl': 1.2} | Passed |
| generated control 4 | {'class': 'medium', 'gi': 48, 'gl': 17.5} | {'class': 'medium', 'gi': 48, 'gl': 17.5} | Passed |
SHA-256 / e29452712d972721db1ad94786240921747744ecb2c4f23ba6e1ffe4e89cc8ac
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.255685+00:00.
Case digest / 0a41bdee33c3c02754449cc3e468f6c092f86ef927d47558feb09bb581452e46