FAILURE MAP
← Case archive

FA-97231 / Recipe scaling and nutrition / Open access

Meal glycemic load: meal GI weighting · case 01

A meal of mostly lentils and a slice of bread reports the plain average of their GIs.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Meal GI is an unweighted mean instead of weighted by available carbohydrate.

VERIFIED REPAIR

Weight each GI by its available carbohydrate.

Unsuccessful approach: Weighting by grams eaten ignores how much carbohydrate each food supplies.

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(Fraction(sum(f[1] for f in foods), len(foods)) + 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: meal GI weighting', [[['lentils', 32, 20, 8, 80, 100], ['rice', 73, 28, 0.4, 30, 100]]],
   {'class': 'low', 'gi': 51, 'gl': 9.1}],
  ['repair check: meal GI weighting',
   [[['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 37.2}],
  ['generated control 1', [[['apple', 36, 14, 2.4, 120, 50]]], {'class': 'medium', 'gi': 36, 'gl': 10.0}],
  ['generated control 2',
   [[['rice', 73, 28, 0.4, 120, 100], ['juice', 50, 10, 0, 50, 50], ['apple', 36, 14, 2.4, 80, 100],
     ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 40.8}],
  ['generated control 3',
   [[['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 80, 100], ['apple', 36, 14, 2.4, 150, 100],
     ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 44, 'gl': 27.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}],
  ['regression: meal GI weighting',
   [[['oats', 55, 60, 10, 50, 50], ['banana', 51, 23, 2.6, 50, 100], ['apple', 36, 14, 2.4, 150, 100]]],
   {'class': 'high', 'gi': 50, 'gl': 39.0}],
  ['repair check: meal GI weighting',
   [[['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 200, 50], ['banana', 51, 23, 2.6, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 174.5}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 150, 50], ['oats', 55, 60, 10, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 145.4}],
  ['generated control 2',
   [[['juice', 50, 10, 0, 120, 100], ['lentils', 32, 20, 8, 50, 100], ['bread', 75, 49, 2.7, 150, 50]]],
   {'class': 'high', 'gi': 71, 'gl': 112.1}],
  ['generated control 3',
   [[['bread', 75, 49, 2.7, 50, 100], ['rice', 73, 28, 0.4, 200, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 71, 'gl': 101.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}],
  ['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
  ['regression: meal GI weighting', [[['bread', 75, 49, 2.7, 200, 100], ['juice', 50, 10, 0, 50, 50]]],
   {'class': 'high', 'gi': 73, 'gl': 74.5}],
  ['repair check: meal GI weighting',
   [[['bread', 75, 49, 2.7, 120, 50], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 100],
     ['juice', 50, 10, 0, 200, 100]]],
   {'class': 'high', 'gi': 69, 'gl': 98.4}],
  ['generated control 1',
   [[['lentils', 32, 20, 8, 50, 50], ['oats', 55, 60, 10, 200, 100], ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 52, 'gl': 67.2}],
  ['generated control 2',
   [[['bread', 75, 49, 2.7, 120, 100], ['oats', 55, 60, 10, 150, 50], ['lentils', 32, 20, 8, 30, 50]]],
   {'class': 'high', 'gi': 59, 'gl': 126.5}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 200, 50]]], {'class': 'high', 'gi': 75, 'gl': 138.9}]],
 [['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: meal GI weighting',
   [[['rice', 73, 28, 0.4, 80, 100], ['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 80, 100]]],
   {'class': 'high', 'gi': 64, 'gl': 63.9}],
  ['repair check: meal GI weighting',
   [[['banana', 51, 23, 2.6, 150, 100], ['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 47, 'gl': 34.4}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 30, 100], ['rice', 73, 28, 0.4, 80, 100]]],
   {'class': 'high', 'gi': 74, 'gl': 26.5}],
  ['generated control 2',
   [[['oats', 55, 60, 10, 30, 100], ['rice', 73, 28, 0.4, 200, 50], ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 92.0}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 150, 100], ['lentils', 32, 20, 8, 120, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 61.3}]],
 [['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: meal GI weighting',
   [[['banana', 51, 23, 2.6, 30, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 50, 100],
     ['juice', 50, 10, 0, 150, 100]]],
   {'class': 'high', 'gi': 54, 'gl': 78.7}],
  ['repair check: meal GI weighting',
   [[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 200, 50]]],
   {'class': 'high', 'gi': 52, 'gl': 101.2}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 200, 100]]], {'class': 'high', 'gi': 75, 'gl': 69.5}],
  ['generated control 2',
   [[['lentils', 32, 20, 8, 50, 100], ['rice', 73, 28, 0.4, 120, 100], ['banana', 51, 23, 2.6, 200, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 46.9}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 80, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 58.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 fixtureActualExpectedOutcome
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: meal GI weighting{'class': 'low', 'gi': 53, 'gl': 9.1}{'class': 'low', 'gi': 51, 'gl': 9.1}Failed
repair check: meal GI weighting{'class': 'high', 'gi': 52, 'gl': 37.2}{'class': 'high', 'gi': 62, 'gl': 37.2}Failed
generated control 1{'class': 'medium', 'gi': 36, 'gl': 10.0}{'class': 'medium', 'gi': 36, 'gl': 10.0}Passed
generated control 2{'class': 'high', 'gi': 53, 'gl': 40.8}{'class': 'high', 'gi': 59, 'gl': 40.8}Failed
generated control 3{'class': 'high', 'gi': 42, 'gl': 27.5}{'class': 'high', 'gi': 44, 'gl': 27.5}Failed

SHA-256 / 27bae2be8630cfea505517a0ae875fc8785e379f553e6fb2d6efe7b2799b05c0

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(sum(f[1] * f[4] for f in foods) / Fraction(sum(f[4] for f in foods)) + 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: meal GI weighting', [[['lentils', 32, 20, 8, 80, 100], ['rice', 73, 28, 0.4, 30, 100]]],
   {'class': 'low', 'gi': 51, 'gl': 9.1}],
  ['repair check: meal GI weighting',
   [[['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 37.2}],
  ['generated control 1', [[['apple', 36, 14, 2.4, 120, 50]]], {'class': 'medium', 'gi': 36, 'gl': 10.0}],
  ['generated control 2',
   [[['rice', 73, 28, 0.4, 120, 100], ['juice', 50, 10, 0, 50, 50], ['apple', 36, 14, 2.4, 80, 100],
     ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 40.8}],
  ['generated control 3',
   [[['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 80, 100], ['apple', 36, 14, 2.4, 150, 100],
     ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 44, 'gl': 27.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}],
  ['regression: meal GI weighting',
   [[['oats', 55, 60, 10, 50, 50], ['banana', 51, 23, 2.6, 50, 100], ['apple', 36, 14, 2.4, 150, 100]]],
   {'class': 'high', 'gi': 50, 'gl': 39.0}],
  ['repair check: meal GI weighting',
   [[['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 200, 50], ['banana', 51, 23, 2.6, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 174.5}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 150, 50], ['oats', 55, 60, 10, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 145.4}],
  ['generated control 2',
   [[['juice', 50, 10, 0, 120, 100], ['lentils', 32, 20, 8, 50, 100], ['bread', 75, 49, 2.7, 150, 50]]],
   {'class': 'high', 'gi': 71, 'gl': 112.1}],
  ['generated control 3',
   [[['bread', 75, 49, 2.7, 50, 100], ['rice', 73, 28, 0.4, 200, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 71, 'gl': 101.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}],
  ['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
  ['regression: meal GI weighting', [[['bread', 75, 49, 2.7, 200, 100], ['juice', 50, 10, 0, 50, 50]]],
   {'class': 'high', 'gi': 73, 'gl': 74.5}],
  ['repair check: meal GI weighting',
   [[['bread', 75, 49, 2.7, 120, 50], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 100],
     ['juice', 50, 10, 0, 200, 100]]],
   {'class': 'high', 'gi': 69, 'gl': 98.4}],
  ['generated control 1',
   [[['lentils', 32, 20, 8, 50, 50], ['oats', 55, 60, 10, 200, 100], ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 52, 'gl': 67.2}],
  ['generated control 2',
   [[['bread', 75, 49, 2.7, 120, 100], ['oats', 55, 60, 10, 150, 50], ['lentils', 32, 20, 8, 30, 50]]],
   {'class': 'high', 'gi': 59, 'gl': 126.5}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 200, 50]]], {'class': 'high', 'gi': 75, 'gl': 138.9}]],
 [['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: meal GI weighting',
   [[['rice', 73, 28, 0.4, 80, 100], ['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 80, 100]]],
   {'class': 'high', 'gi': 64, 'gl': 63.9}],
  ['repair check: meal GI weighting',
   [[['banana', 51, 23, 2.6, 150, 100], ['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 47, 'gl': 34.4}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 30, 100], ['rice', 73, 28, 0.4, 80, 100]]],
   {'class': 'high', 'gi': 74, 'gl': 26.5}],
  ['generated control 2',
   [[['oats', 55, 60, 10, 30, 100], ['rice', 73, 28, 0.4, 200, 50], ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 92.0}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 150, 100], ['lentils', 32, 20, 8, 120, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 61.3}]],
 [['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: meal GI weighting',
   [[['banana', 51, 23, 2.6, 30, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 50, 100],
     ['juice', 50, 10, 0, 150, 100]]],
   {'class': 'high', 'gi': 54, 'gl': 78.7}],
  ['repair check: meal GI weighting',
   [[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 200, 50]]],
   {'class': 'high', 'gi': 52, 'gl': 101.2}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 200, 100]]], {'class': 'high', 'gi': 75, 'gl': 69.5}],
  ['generated control 2',
   [[['lentils', 32, 20, 8, 50, 100], ['rice', 73, 28, 0.4, 120, 100], ['banana', 51, 23, 2.6, 200, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 46.9}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 80, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 58.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 fixtureActualExpectedOutcome
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: meal GI weighting{'class': 'low', 'gi': 43, 'gl': 9.1}{'class': 'low', 'gi': 51, 'gl': 9.1}Failed
repair check: meal GI weighting{'class': 'high', 'gi': 61, 'gl': 37.2}{'class': 'high', 'gi': 62, 'gl': 37.2}Failed
generated control 1{'class': 'medium', 'gi': 36, 'gl': 10.0}{'class': 'medium', 'gi': 36, 'gl': 10.0}Passed
generated control 2{'class': 'high', 'gi': 55, 'gl': 40.8}{'class': 'high', 'gi': 59, 'gl': 40.8}Failed
generated control 3{'class': 'high', 'gi': 41, 'gl': 27.5}{'class': 'high', 'gi': 44, 'gl': 27.5}Failed

SHA-256 / ba0f496e2dfc01e258e199025d3da5b6b9f549888a53d3eba37e594e50fdd322

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: meal GI weighting', [[['lentils', 32, 20, 8, 80, 100], ['rice', 73, 28, 0.4, 30, 100]]],
   {'class': 'low', 'gi': 51, 'gl': 9.1}],
  ['repair check: meal GI weighting',
   [[['rice', 73, 28, 0.4, 150, 100], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 37.2}],
  ['generated control 1', [[['apple', 36, 14, 2.4, 120, 50]]], {'class': 'medium', 'gi': 36, 'gl': 10.0}],
  ['generated control 2',
   [[['rice', 73, 28, 0.4, 120, 100], ['juice', 50, 10, 0, 50, 50], ['apple', 36, 14, 2.4, 80, 100],
     ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 40.8}],
  ['generated control 3',
   [[['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 80, 100], ['apple', 36, 14, 2.4, 150, 100],
     ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 44, 'gl': 27.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}],
  ['regression: meal GI weighting',
   [[['oats', 55, 60, 10, 50, 50], ['banana', 51, 23, 2.6, 50, 100], ['apple', 36, 14, 2.4, 150, 100]]],
   {'class': 'high', 'gi': 50, 'gl': 39.0}],
  ['repair check: meal GI weighting',
   [[['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 200, 50], ['banana', 51, 23, 2.6, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 174.5}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 150, 50], ['oats', 55, 60, 10, 150, 100]]],
   {'class': 'high', 'gi': 68, 'gl': 145.4}],
  ['generated control 2',
   [[['juice', 50, 10, 0, 120, 100], ['lentils', 32, 20, 8, 50, 100], ['bread', 75, 49, 2.7, 150, 50]]],
   {'class': 'high', 'gi': 71, 'gl': 112.1}],
  ['generated control 3',
   [[['bread', 75, 49, 2.7, 50, 100], ['rice', 73, 28, 0.4, 200, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 71, 'gl': 101.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}],
  ['single food', [[['rice', 73, 28, 0.4, 150, 100]]], {'class': 'high', 'gi': 73, 'gl': 30.2}],
  ['regression: meal GI weighting', [[['bread', 75, 49, 2.7, 200, 100], ['juice', 50, 10, 0, 50, 50]]],
   {'class': 'high', 'gi': 73, 'gl': 74.5}],
  ['repair check: meal GI weighting',
   [[['bread', 75, 49, 2.7, 120, 50], ['banana', 51, 23, 2.6, 30, 100], ['lentils', 32, 20, 8, 50, 100],
     ['juice', 50, 10, 0, 200, 100]]],
   {'class': 'high', 'gi': 69, 'gl': 98.4}],
  ['generated control 1',
   [[['lentils', 32, 20, 8, 50, 50], ['oats', 55, 60, 10, 200, 100], ['banana', 51, 23, 2.6, 80, 100]]],
   {'class': 'high', 'gi': 52, 'gl': 67.2}],
  ['generated control 2',
   [[['bread', 75, 49, 2.7, 120, 100], ['oats', 55, 60, 10, 150, 50], ['lentils', 32, 20, 8, 30, 50]]],
   {'class': 'high', 'gi': 59, 'gl': 126.5}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 200, 50]]], {'class': 'high', 'gi': 75, 'gl': 138.9}]],
 [['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: meal GI weighting',
   [[['rice', 73, 28, 0.4, 80, 100], ['juice', 50, 10, 0, 200, 50], ['bread', 75, 49, 2.7, 80, 100]]],
   {'class': 'high', 'gi': 64, 'gl': 63.9}],
  ['repair check: meal GI weighting',
   [[['banana', 51, 23, 2.6, 150, 100], ['juice', 50, 10, 0, 150, 50], ['lentils', 32, 20, 8, 50, 50]]],
   {'class': 'high', 'gi': 47, 'gl': 34.4}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 30, 100], ['rice', 73, 28, 0.4, 80, 100]]],
   {'class': 'high', 'gi': 74, 'gl': 26.5}],
  ['generated control 2',
   [[['oats', 55, 60, 10, 30, 100], ['rice', 73, 28, 0.4, 200, 50], ['banana', 51, 23, 2.6, 30, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 92.0}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 150, 100], ['lentils', 32, 20, 8, 120, 50]]],
   {'class': 'high', 'gi': 62, 'gl': 61.3}]],
 [['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: meal GI weighting',
   [[['banana', 51, 23, 2.6, 30, 100], ['oats', 55, 60, 10, 120, 50], ['apple', 36, 14, 2.4, 50, 100],
     ['juice', 50, 10, 0, 150, 100]]],
   {'class': 'high', 'gi': 54, 'gl': 78.7}],
  ['repair check: meal GI weighting',
   [[['oats', 55, 60, 10, 200, 100], ['lentils', 32, 20, 8, 120, 100], ['banana', 51, 23, 2.6, 200, 50]]],
   {'class': 'high', 'gi': 52, 'gl': 101.2}],
  ['generated control 1', [[['bread', 75, 49, 2.7, 200, 100]]], {'class': 'high', 'gi': 75, 'gl': 69.5}],
  ['generated control 2',
   [[['lentils', 32, 20, 8, 50, 100], ['rice', 73, 28, 0.4, 120, 100], ['banana', 51, 23, 2.6, 200, 100]]],
   {'class': 'high', 'gi': 59, 'gl': 46.9}],
  ['generated control 3', [[['bread', 75, 49, 2.7, 80, 50], ['lentils', 32, 20, 8, 80, 100]]],
   {'class': 'high', 'gi': 70, 'gl': 58.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 fixtureActualExpectedOutcome
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: meal GI weighting{'class': 'low', 'gi': 51, 'gl': 9.1}{'class': 'low', 'gi': 51, 'gl': 9.1}Passed
repair check: meal GI weighting{'class': 'high', 'gi': 62, 'gl': 37.2}{'class': 'high', 'gi': 62, 'gl': 37.2}Passed
generated control 1{'class': 'medium', 'gi': 36, 'gl': 10.0}{'class': 'medium', 'gi': 36, 'gl': 10.0}Passed
generated control 2{'class': 'high', 'gi': 59, 'gl': 40.8}{'class': 'high', 'gi': 59, 'gl': 40.8}Passed
generated control 3{'class': 'high', 'gi': 44, 'gl': 27.5}{'class': 'high', 'gi': 44, 'gl': 27.5}Passed

SHA-256 / 666a3de519f38eb792edab18bc99f9e7d8b924da0e5b9803637064457ae53772

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.202544+00:00.

Case digest / a8559c3cf6fc6c4486c4864d34a1654be9a26f9ef200178e1b634ecfa67d5c59