FA-96846 / Recipe scaling and nutrition / Open access
Servings scaler: seasoning damping · case 01
Salt and spices come out at three quarters of even the unscaled amount.
ROOT CAUSE
Seasoning multiplies the whole factor by 3/4 instead of damping only the change (f-1) by 3/4.
THE FAILURE
Seasoning multiplies the whole factor by 3/4 instead of damping only the change (f-1) by 3/4.
Unsuccessful approach: Applying the damping only on scale-ups leaves scale-downs linear, so reduced batches lose too much seasoning.
Case contract
Scale [name, qty, unit, kind] rows from base to target servings. Factor f=target/base (both must be positive, else an error string). Seasoning rows scale by 1+(f-1)*3/4 (damped); other rows by f. Unit "each" rounds half-up to an integer with a floor of 1. Other units round half-up to the nearest 1/8 and print as reduced kitchen fractions ("1 1/2", "3/4", "2"); a zero result prints "pinch".
Why this case matters
Home and commercial recipe scalers must keep countable items whole and print measurable fractions cooks can actually portion.
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(items, base, target):
if base <= 0 or target <= 0:
return 'error: servings must be positive'
f = Fraction(target, base)
def fmt(e):
if e == 0:
return 'pinch'
whole, rem = divmod(e, 8)
if rem == 0:
return str(whole)
g = math.gcd(rem, 8)
frac = '%d/%d' % (rem // g, 8 // g)
return frac if whole == 0 else '%d %s' % (whole, frac)
out = []
for name, qty, unit, kind in items:
q = Fraction(qty)
if kind == 'seasoning':
s = q * f * Fraction(3, 4)
else:
s = q * f
if unit == 'each':
n = int(s) + (1 if s - int(s) >= Fraction(1, 2) else 0)
out.append([name, str(max(1, n)), unit])
else:
e = int(s * 8 + Fraction(1, 2))
out.append([name, fmt(e), unit])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['regression: seasoning damping',
[[['butter', '3/2', 'tbsp', 'base'], ['cumin', '1', 'tsp', 'seasoning'], ['flour', '9/4', 'cup', 'base']],
1, 4],
[['butter', '6', 'tbsp'], ['cumin', '3 1/4', 'tsp'], ['flour', '9', 'cup']]],
['repair check: seasoning damping',
[[['butter', '1/2', 'tbsp', 'base'], ['garlic clove', '1/2', 'each', 'base'],
['cumin', '2/3', 'tsp', 'seasoning']],
8, 1],
[['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/4', 'tsp']]],
['generated control 1', [[['flour', '2/3', 'cup', 'base'], ['milk', '9/4', 'cup', 'base']], 1, 5],
[['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']]],
['generated control 2', [[['flour', '1/4', 'cup', 'base'], ['lime', '1', 'each', 'base']], 4, 2],
[['flour', '1/8', 'cup'], ['lime', '1', 'each']]],
['generated control 3',
[[['garlic clove', '1/2', 'each', 'base'], ['egg', '5', 'each', 'base'], ['butter', '1/2', 'tbsp', 'base'],
['lime', '1', 'each', 'base'], ['cumin', '1/4', 'tsp', 'seasoning']],
1, 2],
[['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'],
['cumin', '1/2', 'tsp']]]],
[['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['regression: seasoning damping',
[[['pepper', '5/2', 'tsp', 'seasoning'], ['egg', '1', 'each', 'base'],
['garlic clove', '4', 'each', 'base']],
5, 1],
[['pepper', '1', 'tsp'], ['egg', '1', 'each'], ['garlic clove', '1', 'each']]],
['repair check: seasoning damping',
[[['flour', '9/4', 'cup', 'base'], ['cumin', '1/8', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base'],
['lime', '2', 'each', 'base'], ['milk', '1/8', 'cup', 'base']],
6, 2],
[['flour', '3/4', 'cup'], ['cumin', '1/8', 'tsp'], ['egg', '1', 'each'], ['lime', '1', 'each'],
['milk', 'pinch', 'cup']]],
['generated control 1', [[['lime', '3', 'each', 'base'], ['butter', '3', 'tbsp', 'base']], 4, 11],
[['lime', '8', 'each'], ['butter', '8 1/4', 'tbsp']]],
['generated control 2',
[[['garlic clove', '1', 'each', 'base'], ['milk', '2', 'cup', 'base'], ['lime', '4', 'each', 'base'],
['cumin', '1/8', 'tsp', 'seasoning'], ['butter', '1/8', 'tbsp', 'base']],
2, 1],
[['garlic clove', '1', 'each'], ['milk', '1', 'cup'], ['lime', '2', 'each'], ['cumin', '1/8', 'tsp'],
['butter', '1/8', 'tbsp']]],
['generated control 3',
[[['cumin', '1/2', 'tsp', 'seasoning'], ['flour', '2', 'cup', 'base'], ['egg', '3', 'each', 'base']], 8,
9],
[['cumin', '1/2', 'tsp'], ['flour', '2 1/4', 'cup'], ['egg', '3', 'each']]]],
[['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['regression: seasoning damping',
[[['egg', '2', 'each', 'base'], ['cumin', '1/3', 'tsp', 'seasoning'], ['salt', '1/4', 'tsp', 'seasoning'],
['butter', '3/2', 'tbsp', 'base'], ['garlic clove', '5', 'each', 'base']],
4, 12],
[['egg', '6', 'each'], ['cumin', '7/8', 'tsp'], ['salt', '5/8', 'tsp'], ['butter', '4 1/2', 'tbsp'],
['garlic clove', '15', 'each']]],
['repair check: seasoning damping',
[[['cumin', '5/2', 'tsp', 'seasoning'], ['lime', '1/2', 'each', 'base'], ['flour', '3', 'cup', 'base'],
['pepper', '1/8', 'tsp', 'seasoning'], ['egg', '5', 'each', 'base']],
8, 5],
[['cumin', '1 3/4', 'tsp'], ['lime', '1', 'each'], ['flour', '1 7/8', 'cup'], ['pepper', '1/8', 'tsp'],
['egg', '3', 'each']]],
['generated control 1', [[['egg', '1', 'each', 'base'], ['butter', '1', 'tbsp', 'base']], 6, 12],
[['egg', '2', 'each'], ['butter', '2', 'tbsp']]],
['generated control 2',
[[['butter', '1/8', 'tbsp', 'base'], ['garlic clove', '1/2', 'each', 'base'],
['flour', '3/2', 'cup', 'base']],
4, 12],
[['butter', '3/8', 'tbsp'], ['garlic clove', '2', 'each'], ['flour', '4 1/2', 'cup']]],
['generated control 3',
[[['pepper', '5/2', 'tsp', 'seasoning'], ['flour', '2', 'cup', 'base'], ['egg', '2', 'each', 'base'],
['milk', '1/4', 'cup', 'base'], ['butter', '2', 'tbsp', 'base']],
2, 12],
[['pepper', '11 7/8', 'tsp'], ['flour', '12', 'cup'], ['egg', '12', 'each'], ['milk', '1 1/2', 'cup'],
['butter', '12', 'tbsp']]]],
[['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['regression: seasoning damping',
[[['cumin', '2', 'tsp', 'seasoning'], ['milk', '1/2', 'cup', 'base']], 5, 8],
[['cumin', '2 7/8', 'tsp'], ['milk', '3/4', 'cup']]],
['repair check: seasoning damping',
[[['cumin', '1', 'tsp', 'seasoning'], ['pepper', '1/4', 'tsp', 'seasoning'],
['butter', '1/3', 'tbsp', 'base'], ['garlic clove', '3', 'each', 'base']],
8, 1],
[['cumin', '3/8', 'tsp'], ['pepper', '1/8', 'tsp'], ['butter', 'pinch', 'tbsp'],
['garlic clove', '1', 'each']]],
['generated control 1', [[['cumin', '2', 'tsp', 'seasoning'], ['salt', '1/2', 'tsp', 'seasoning']], 5, 9],
[['cumin', '3 1/4', 'tsp'], ['salt', '3/4', 'tsp']]],
['generated control 2',
[[['garlic clove', '1/2', 'each', 'base'], ['egg', '1/2', 'each', 'base'], ['milk', '1/8', 'cup', 'base']],
6, 9],
[['garlic clove', '1', 'each'], ['egg', '1', 'each'], ['milk', '1/4', 'cup']]],
['generated control 3', [[['milk', '1/4', 'cup', 'base'], ['butter', '1/4', 'tbsp', 'base']], 7, 8],
[['milk', '1/4', 'cup'], ['butter', '1/4', 'tbsp']]]],
[['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['regression: seasoning damping',
[[['lime', '3', 'each', 'base'], ['cumin', '1/8', 'tsp', 'seasoning'], ['egg', '1', 'each', 'base'],
['garlic clove', '5', 'each', 'base'], ['pepper', '5/2', 'tsp', 'seasoning']],
7, 7],
[['lime', '3', 'each'], ['cumin', '1/8', 'tsp'], ['egg', '1', 'each'], ['garlic clove', '5', 'each'],
['pepper', '2 1/2', 'tsp']]],
['repair check: seasoning damping',
[[['pepper', '3', 'tsp', 'seasoning'], ['salt', '3/2', 'tsp', 'seasoning']], 4, 3],
[['pepper', '2 1/2', 'tsp'], ['salt', '1 1/4', 'tsp']]],
['generated control 1',
[[['salt', '5/2', 'tsp', 'seasoning'], ['milk', '1/4', 'cup', 'base'], ['butter', '1', 'tbsp', 'base'],
['cumin', '1/3', 'tsp', 'seasoning']],
8, 11],
[['salt', '3 1/4', 'tsp'], ['milk', '3/8', 'cup'], ['butter', '1 3/8', 'tbsp'], ['cumin', '3/8', 'tsp']]],
['generated control 2',
[[['salt', '1/4', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base'], ['cumin', '1/2', 'tsp', 'seasoning'],
['flour', '1/2', 'cup', 'base'], ['lime', '5', 'each', 'base']],
5, 11],
[['salt', '1/2', 'tsp'], ['egg', '7', 'each'], ['cumin', '1', 'tsp'], ['flour', '1 1/8', 'cup'],
['lime', '11', 'each']]],
['generated control 3',
[[['butter', '1', 'tbsp', 'base'], ['pepper', '2', 'tsp', 'seasoning'], ['egg', '4', 'each', 'base']], 1,
12],
[['butter', '12', 'tbsp'], ['pepper', '18 1/2', 'tsp'], ['egg', '48', 'each']]]]]
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 |
|---|---|---|---|
| identity scaling control | [['egg', '2', 'each'], ['flour', '1 1/2', 'cup']] | [['egg', '2', 'each'], ['flour', '1 1/2', 'cup']] | Passed |
| zero servings rejected | error: servings must be positive | error: servings must be positive | Passed |
| double batch with seasoning | [['salt', '1 1/2', 'tsp'], ['egg', '6', 'each']] | [['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']] | Failed |
| regression: seasoning damping | [['butter', '6', 'tbsp'], ['cumin', '3', 'tsp'], ['flour', '9', 'cup']] | [['butter', '6', 'tbsp'], ['cumin', '3 1/4', 'tsp'], ['flour', '9', 'cup']] | Failed |
| repair check: seasoning damping | [['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/8', 'tsp']] | [['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/4', 'tsp']] | Failed |
| generated control 1 | [['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']] | [['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']] | Passed |
| generated control 2 | [['flour', '1/8', 'cup'], ['lime', '1', 'each']] | [['flour', '1/8', 'cup'], ['lime', '1', 'each']] | Passed |
| generated control 3 | [['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'], ['cumin', '3/8', 'tsp']] | [['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'], ['cumin', '1/2', 'tsp']] | Failed |
SHA-256 / 7f92a82c2eeba9bf2a3f87b51ff6073e316645adbb99ea1b61db26d43e18fcc9
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(items, base, target):
if base <= 0 or target <= 0:
return 'error: servings must be positive'
f = Fraction(target, base)
def fmt(e):
if e == 0:
return 'pinch'
whole, rem = divmod(e, 8)
if rem == 0:
return str(whole)
g = math.gcd(rem, 8)
frac = '%d/%d' % (rem // g, 8 // g)
return frac if whole == 0 else '%d %s' % (whole, frac)
out = []
for name, qty, unit, kind in items:
q = Fraction(qty)
if kind == 'seasoning':
s = q * (1 + (f - 1) * Fraction(3, 4)) if f > 1 else q * f
else:
s = q * f
if unit == 'each':
n = int(s) + (1 if s - int(s) >= Fraction(1, 2) else 0)
out.append([name, str(max(1, n)), unit])
else:
e = int(s * 8 + Fraction(1, 2))
out.append([name, fmt(e), unit])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['regression: seasoning damping',
[[['butter', '3/2', 'tbsp', 'base'], ['cumin', '1', 'tsp', 'seasoning'], ['flour', '9/4', 'cup', 'base']],
1, 4],
[['butter', '6', 'tbsp'], ['cumin', '3 1/4', 'tsp'], ['flour', '9', 'cup']]],
['repair check: seasoning damping',
[[['butter', '1/2', 'tbsp', 'base'], ['garlic clove', '1/2', 'each', 'base'],
['cumin', '2/3', 'tsp', 'seasoning']],
8, 1],
[['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/4', 'tsp']]],
['generated control 1', [[['flour', '2/3', 'cup', 'base'], ['milk', '9/4', 'cup', 'base']], 1, 5],
[['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']]],
['generated control 2', [[['flour', '1/4', 'cup', 'base'], ['lime', '1', 'each', 'base']], 4, 2],
[['flour', '1/8', 'cup'], ['lime', '1', 'each']]],
['generated control 3',
[[['garlic clove', '1/2', 'each', 'base'], ['egg', '5', 'each', 'base'], ['butter', '1/2', 'tbsp', 'base'],
['lime', '1', 'each', 'base'], ['cumin', '1/4', 'tsp', 'seasoning']],
1, 2],
[['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'],
['cumin', '1/2', 'tsp']]]],
[['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['regression: seasoning damping',
[[['pepper', '5/2', 'tsp', 'seasoning'], ['egg', '1', 'each', 'base'],
['garlic clove', '4', 'each', 'base']],
5, 1],
[['pepper', '1', 'tsp'], ['egg', '1', 'each'], ['garlic clove', '1', 'each']]],
['repair check: seasoning damping',
[[['flour', '9/4', 'cup', 'base'], ['cumin', '1/8', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base'],
['lime', '2', 'each', 'base'], ['milk', '1/8', 'cup', 'base']],
6, 2],
[['flour', '3/4', 'cup'], ['cumin', '1/8', 'tsp'], ['egg', '1', 'each'], ['lime', '1', 'each'],
['milk', 'pinch', 'cup']]],
['generated control 1', [[['lime', '3', 'each', 'base'], ['butter', '3', 'tbsp', 'base']], 4, 11],
[['lime', '8', 'each'], ['butter', '8 1/4', 'tbsp']]],
['generated control 2',
[[['garlic clove', '1', 'each', 'base'], ['milk', '2', 'cup', 'base'], ['lime', '4', 'each', 'base'],
['cumin', '1/8', 'tsp', 'seasoning'], ['butter', '1/8', 'tbsp', 'base']],
2, 1],
[['garlic clove', '1', 'each'], ['milk', '1', 'cup'], ['lime', '2', 'each'], ['cumin', '1/8', 'tsp'],
['butter', '1/8', 'tbsp']]],
['generated control 3',
[[['cumin', '1/2', 'tsp', 'seasoning'], ['flour', '2', 'cup', 'base'], ['egg', '3', 'each', 'base']], 8,
9],
[['cumin', '1/2', 'tsp'], ['flour', '2 1/4', 'cup'], ['egg', '3', 'each']]]],
[['double batch with seasoning', [[['salt', '1', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base']], 4, 8],
[['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']]],
['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['regression: seasoning damping',
[[['egg', '2', 'each', 'base'], ['cumin', '1/3', 'tsp', 'seasoning'], ['salt', '1/4', 'tsp', 'seasoning'],
['butter', '3/2', 'tbsp', 'base'], ['garlic clove', '5', 'each', 'base']],
4, 12],
[['egg', '6', 'each'], ['cumin', '7/8', 'tsp'], ['salt', '5/8', 'tsp'], ['butter', '4 1/2', 'tbsp'],
['garlic clove', '15', 'each']]],
['repair check: seasoning damping',
[[['cumin', '5/2', 'tsp', 'seasoning'], ['lime', '1/2', 'each', 'base'], ['flour', '3', 'cup', 'base'],
['pepper', '1/8', 'tsp', 'seasoning'], ['egg', '5', 'each', 'base']],
8, 5],
[['cumin', '1 3/4', 'tsp'], ['lime', '1', 'each'], ['flour', '1 7/8', 'cup'], ['pepper', '1/8', 'tsp'],
['egg', '3', 'each']]],
['generated control 1', [[['egg', '1', 'each', 'base'], ['butter', '1', 'tbsp', 'base']], 6, 12],
[['egg', '2', 'each'], ['butter', '2', 'tbsp']]],
['generated control 2',
[[['butter', '1/8', 'tbsp', 'base'], ['garlic clove', '1/2', 'each', 'base'],
['flour', '3/2', 'cup', 'base']],
4, 12],
[['butter', '3/8', 'tbsp'], ['garlic clove', '2', 'each'], ['flour', '4 1/2', 'cup']]],
['generated control 3',
[[['pepper', '5/2', 'tsp', 'seasoning'], ['flour', '2', 'cup', 'base'], ['egg', '2', 'each', 'base'],
['milk', '1/4', 'cup', 'base'], ['butter', '2', 'tbsp', 'base']],
2, 12],
[['pepper', '11 7/8', 'tsp'], ['flour', '12', 'cup'], ['egg', '12', 'each'], ['milk', '1 1/2', 'cup'],
['butter', '12', 'tbsp']]]],
[['tiny scale-down to pinch', [[['cumin', '1/8', 'tsp', 'base'], ['egg', '1', 'each', 'base']], 8, 1],
[['cumin', 'pinch', 'tsp'], ['egg', '1', 'each']]],
['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['regression: seasoning damping',
[[['cumin', '2', 'tsp', 'seasoning'], ['milk', '1/2', 'cup', 'base']], 5, 8],
[['cumin', '2 7/8', 'tsp'], ['milk', '3/4', 'cup']]],
['repair check: seasoning damping',
[[['cumin', '1', 'tsp', 'seasoning'], ['pepper', '1/4', 'tsp', 'seasoning'],
['butter', '1/3', 'tbsp', 'base'], ['garlic clove', '3', 'each', 'base']],
8, 1],
[['cumin', '3/8', 'tsp'], ['pepper', '1/8', 'tsp'], ['butter', 'pinch', 'tbsp'],
['garlic clove', '1', 'each']]],
['generated control 1', [[['cumin', '2', 'tsp', 'seasoning'], ['salt', '1/2', 'tsp', 'seasoning']], 5, 9],
[['cumin', '3 1/4', 'tsp'], ['salt', '3/4', 'tsp']]],
['generated control 2',
[[['garlic clove', '1/2', 'each', 'base'], ['egg', '1/2', 'each', 'base'], ['milk', '1/8', 'cup', 'base']],
6, 9],
[['garlic clove', '1', 'each'], ['egg', '1', 'each'], ['milk', '1/4', 'cup']]],
['generated control 3', [[['milk', '1/4', 'cup', 'base'], ['butter', '1/4', 'tbsp', 'base']], 7, 8],
[['milk', '1/4', 'cup'], ['butter', '1/4', 'tbsp']]]],
[['half egg rounds up', [[['egg', '3', 'each', 'base'], ['milk', '1/2', 'cup', 'base']], 4, 6],
[['egg', '5', 'each'], ['milk', '3/4', 'cup']]],
['identity scaling control', [[['egg', '2', 'each', 'base'], ['flour', '3/2', 'cup', 'base']], 4, 4],
[['egg', '2', 'each'], ['flour', '1 1/2', 'cup']]],
['zero servings rejected', [[['egg', '2', 'each', 'base']], 0, 4], 'error: servings must be positive'],
['regression: seasoning damping',
[[['lime', '3', 'each', 'base'], ['cumin', '1/8', 'tsp', 'seasoning'], ['egg', '1', 'each', 'base'],
['garlic clove', '5', 'each', 'base'], ['pepper', '5/2', 'tsp', 'seasoning']],
7, 7],
[['lime', '3', 'each'], ['cumin', '1/8', 'tsp'], ['egg', '1', 'each'], ['garlic clove', '5', 'each'],
['pepper', '2 1/2', 'tsp']]],
['repair check: seasoning damping',
[[['pepper', '3', 'tsp', 'seasoning'], ['salt', '3/2', 'tsp', 'seasoning']], 4, 3],
[['pepper', '2 1/2', 'tsp'], ['salt', '1 1/4', 'tsp']]],
['generated control 1',
[[['salt', '5/2', 'tsp', 'seasoning'], ['milk', '1/4', 'cup', 'base'], ['butter', '1', 'tbsp', 'base'],
['cumin', '1/3', 'tsp', 'seasoning']],
8, 11],
[['salt', '3 1/4', 'tsp'], ['milk', '3/8', 'cup'], ['butter', '1 3/8', 'tbsp'], ['cumin', '3/8', 'tsp']]],
['generated control 2',
[[['salt', '1/4', 'tsp', 'seasoning'], ['egg', '3', 'each', 'base'], ['cumin', '1/2', 'tsp', 'seasoning'],
['flour', '1/2', 'cup', 'base'], ['lime', '5', 'each', 'base']],
5, 11],
[['salt', '1/2', 'tsp'], ['egg', '7', 'each'], ['cumin', '1', 'tsp'], ['flour', '1 1/8', 'cup'],
['lime', '11', 'each']]],
['generated control 3',
[[['butter', '1', 'tbsp', 'base'], ['pepper', '2', 'tsp', 'seasoning'], ['egg', '4', 'each', 'base']], 1,
12],
[['butter', '12', 'tbsp'], ['pepper', '18 1/2', 'tsp'], ['egg', '48', 'each']]]]]
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 |
|---|---|---|---|
| identity scaling control | [['egg', '2', 'each'], ['flour', '1 1/2', 'cup']] | [['egg', '2', 'each'], ['flour', '1 1/2', 'cup']] | Passed |
| zero servings rejected | error: servings must be positive | error: servings must be positive | Passed |
| double batch with seasoning | [['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']] | [['salt', '1 3/4', 'tsp'], ['egg', '6', 'each']] | Passed |
| regression: seasoning damping | [['butter', '6', 'tbsp'], ['cumin', '3 1/4', 'tsp'], ['flour', '9', 'cup']] | [['butter', '6', 'tbsp'], ['cumin', '3 1/4', 'tsp'], ['flour', '9', 'cup']] | Passed |
| repair check: seasoning damping | [['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/8', 'tsp']] | [['butter', '1/8', 'tbsp'], ['garlic clove', '1', 'each'], ['cumin', '1/4', 'tsp']] | Failed |
| generated control 1 | [['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']] | [['flour', '3 3/8', 'cup'], ['milk', '11 1/4', 'cup']] | Passed |
| generated control 2 | [['flour', '1/8', 'cup'], ['lime', '1', 'each']] | [['flour', '1/8', 'cup'], ['lime', '1', 'each']] | Passed |
| generated control 3 | [['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'], ['cumin', '1/2', 'tsp']] | [['garlic clove', '1', 'each'], ['egg', '10', 'each'], ['butter', '1', 'tbsp'], ['lime', '2', 'each'], ['cumin', '1/2', 'tsp']] | Passed |
SHA-256 / 958fffacdad95c7fda334356be7dc40f2f37fea902c6cb47c4c492156bee999e
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.413330+00:00.
Case digest / fa56dff6d365e782e5cff8c9eaa01ac4a35b2ef9515140cd473e310fa3800226