FAILURE MAP
← Case archive

FA-97241 / Recipe scaling and nutrition / Open access

Sub-recipe allergen roll-up: diamond versus cycle · case 01

A glaze used by both the filling and the topping is reported as a cycle.

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

ROOT CAUSE

Any previously seen node is treated as a cycle, including finished shared sub-recipes.

VERIFIED REPAIR

Report a cycle only for nodes still on the current path.

Unsuccessful approach: Exempting only the root still flags every shared sub-recipe.

Case contract

recipes maps name -> {allergens, may_contain, uses}. Walk root and every used sub-recipe (depth first, in order). Names canonicalize: trim, lower, synonyms dairy->milk, peanuts->peanut, tree nuts->tree nut, eggs->egg. Result {contains, may_contain (minus contains), error: None}, both sorted. A shared sub-recipe reached twice (diamond) is fine; a cycle returns error "cycle: name" and an unknown name "unknown: name", with empty lists, stopping at the first error.

Why this case matters

Menu allergen matrices must propagate through nested sub-recipes without false cycle errors.

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(recipes, root):
    SYN = {'dairy': 'milk', 'peanuts': 'peanut', 'tree nuts': 'tree nut', 'eggs': 'egg'}
    def canon(a):
        a = a.strip().lower()
        return SYN.get(a, a)
    contains, may = set(), set()
    state = {}
    def visit(n):
        if n not in recipes:
            return 'unknown: ' + n
        if n in state:
            return 'cycle: ' + n
        if state.get(n) == 2:
            return None
        state[n] = 1
        r = recipes[n]
        contains.update(canon(a) for a in r.get('allergens', []))
        may.update(canon(a) for a in r.get('may_contain', []))
        for s in r.get('uses', []):
            e = visit(s)
            if e:
                return e
        state[n] = 2
        return None
    err = visit(root)
    if err:
        return {'contains': [], 'may_contain': [], 'error': err}
    return {'contains': sorted(contains), 'may_contain': sorted(may - contains), 'error': None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'peanuts'], 'uses': ['crust', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['Egg', 'wheat'], 'uses': ['filling', 'mystery']},
     'topping': {'allergens': ['dairy', ' sesame '], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts', 'soy'], 'may_contain': [' sesame '], 'uses': ['crust', 'filling']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['tree nuts'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['crust']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [' sesame ', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': []},
     'crust': {'allergens': ['Egg', 'soy'], 'may_contain': ['soy', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['eggs', 'tree nuts'], 'may_contain': ['Egg'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['dairy', 'soy'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'tree nuts'], 'uses': ['mystery']},
     'crust': {'allergens': ['wheat'], 'may_contain': [' sesame ', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['tree nuts', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['peanuts'], 'may_contain': ['Egg'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': ['soy'], 'may_contain': ['tree nuts', 'wheat'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['Egg'], 'uses': []},
     'filling': {'allergens': ['dairy'], 'may_contain': [' sesame '], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['tree nuts', 'Egg'], 'uses': []},
     'topping': {'allergens': [' sesame ', 'tree nuts'], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}]],
 [['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['peanuts', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': ['wheat', 'soy'], 'may_contain': [], 'uses': ['filling']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'wheat'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['peanut', 'soy', 'tree nut', 'wheat'], 'error': None, 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [' sesame '], 'may_contain': [], 'uses': ['crust']},
     'crust': {'allergens': ['Egg', 'milk'],
               'may_contain': ['milk', 'tree nuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['Egg'], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'dairy'], 'may_contain': ['Egg', 'tree nuts'], 'uses': ['filling']},
     'topping': {'allergens': ['eggs', 'tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['milk', 'wheat'], 'uses': ['sauce', 'filling']},
     'crust': {'allergens': [' sesame ', 'wheat'],
               'may_contain': ['peanuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['tree nuts', 'soy'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['peanuts'], 'uses': ['crust']},
     'topping': {'allergens': ['eggs', 'soy'], 'may_contain': ['peanuts'], 'uses': ['mystery']}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['eggs', 'soy'],
              'may_contain': ['tree nuts', 'Egg'],
              'uses': ['filling', 'topping']},
     'crust': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['milk'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': ['dairy', 'wheat'], 'uses': []},
     'sauce': {'allergens': ['soy', 'peanuts'], 'may_contain': [], 'uses': ['crust']},
     'topping': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', 'dairy'], 'uses': ['topping']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy', 'peanuts'], 'uses': []},
     'filling': {'allergens': ['Egg', 'soy'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat'], 'uses': ['filling']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]],
 [['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['wheat'], 'uses': ['sauce']},
     'crust': {'allergens': ['eggs'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [' sesame '],
               'may_contain': ['peanuts', 'tree nuts'],
               'uses': ['crust', 'mystery']},
     'topping': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['peanuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['wheat', 'tree nuts'], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['soy', 'wheat'], 'uses': ['base']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': ['soy'], 'may_contain': ['tree nuts'], 'uses': []},
     'filling': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['dairy', 'tree nuts'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'milk'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'peanut', 'sesame'], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['Egg'], 'uses': ['sauce']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': ['milk', 'dairy'], 'may_contain': ['dairy'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame ', 'peanuts'], 'may_contain': ['milk', 'soy'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['milk', 'soy']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'filling', 'topping', 'mystery']},
     'crust': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': ['topping']},
     'sauce': {'allergens': ['tree nuts', 'peanuts'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['wheat', ' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}]],
 [['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': [' sesame '], 'may_contain': ['dairy'], 'uses': ['topping', 'base', 'mystery']},
     'sauce': {'allergens': [' sesame ', 'soy'],
               'may_contain': ['soy', 'tree nuts'],
               'uses': ['crust', 'topping']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat', 'milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'sesame', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'mystery']},
     'crust': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['milk', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'soy'],
               'may_contain': ['peanuts'],
               'uses': ['crust', 'filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [' sesame '], 'uses': []},
     'crust': {'allergens': ['dairy'], 'may_contain': ['soy', 'wheat'], 'uses': ['filling']},
     'filling': {'allergens': ['soy'], 'may_contain': ['eggs', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['milk', 'soy'], 'may_contain': [' sesame '], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': ['sesame']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'crust': {'allergens': [], 'may_contain': ['tree nuts'], 'uses': ['topping', 'mystery']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk', 'peanuts'], 'may_contain': ['wheat'], 'uses': []},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk', 'Egg'], 'uses': []}},
    'base'],
   {'contains': ['peanut'], 'error': None, 'may_contain': ['egg', 'milk']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['filling']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['wheat'], 'may_contain': ['eggs'], 'uses': []}},
    'base'],
   {'contains': ['wheat'], 'error': None, 'may_contain': ['egg']}]],
 [['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['wheat'],
              'may_contain': [' sesame ', 'dairy'],
              'uses': ['sauce', 'crust', 'topping', 'mystery']},
     'crust': {'allergens': ['peanuts', ' sesame '], 'may_contain': ['eggs', 'milk'], 'uses': ['sauce']},
     'filling': {'allergens': ['peanuts'], 'may_contain': ['Egg', 'dairy'], 'uses': []},
     'sauce': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['peanuts'], 'uses': []},
     'topping': {'allergens': [' sesame '], 'may_contain': ['tree nuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts'], 'may_contain': [' sesame '], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': ['dairy', 'Egg'], 'may_contain': ['milk'], 'uses': []},
     'sauce': {'allergens': ['eggs'], 'may_contain': ['milk', 'tree nuts'], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': ['Egg'], 'may_contain': ['dairy'], 'uses': []},
     'crust': {'allergens': ['milk'], 'may_contain': ['tree nuts'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['milk'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['wheat'], 'may_contain': [], 'uses': ['crust', 'filling', 'base']},
     'topping': {'allergens': [], 'may_contain': ['Egg', ' sesame '], 'uses': ['mystery']}},
    'base'],
   {'contains': ['egg'], 'error': None, 'may_contain': ['milk']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', ' sesame '], 'uses': ['filling']},
     'crust': {'allergens': [], 'may_contain': ['peanuts', 'soy'], 'uses': ['filling', 'mystery']},
     'filling': {'allergens': ['milk', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': [' sesame '], 'may_contain': ['wheat'], 'uses': ['crust', 'topping', 'base']},
     'topping': {'allergens': [], 'may_contain': ['tree nuts', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': ['sesame', 'tree nut']}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'crust': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['dairy', 'eggs'], 'may_contain': [' sesame '], 'uses': ['topping']},
     'sauce': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk'], 'uses': ['sauce']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]]]
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
flat recipe{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}Passed
diamond sharing{'contains': [], 'error': 'cycle: c', 'may_contain': []}{'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}Failed
cycle{'contains': [], 'error': 'cycle: base', 'may_contain': []}{'contains': [], 'error': 'cycle: base', 'may_contain': []}Passed
regression: diamond versus cycle{'contains': [], 'error': 'cycle: topping', 'may_contain': []}{'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}Failed
repair check: diamond versus cycle{'contains': [], 'error': 'cycle: topping', 'may_contain': []}{'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}Failed
generated control 1{'contains': [], 'error': None, 'may_contain': []}{'contains': [], 'error': None, 'may_contain': []}Passed
generated control 2{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}Passed
generated control 3{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}Passed

SHA-256 / 64853a6e307b9dfde6e959b002a663d89ea25d155452647e2c5310253a7cd04e

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(recipes, root):
    SYN = {'dairy': 'milk', 'peanuts': 'peanut', 'tree nuts': 'tree nut', 'eggs': 'egg'}
    def canon(a):
        a = a.strip().lower()
        return SYN.get(a, a)
    contains, may = set(), set()
    state = {}
    def visit(n):
        if n not in recipes:
            return 'unknown: ' + n
        if n in state and n != root:
            return 'cycle: ' + n
        if state.get(n) == 2:
            return None
        state[n] = 1
        r = recipes[n]
        contains.update(canon(a) for a in r.get('allergens', []))
        may.update(canon(a) for a in r.get('may_contain', []))
        for s in r.get('uses', []):
            e = visit(s)
            if e:
                return e
        state[n] = 2
        return None
    err = visit(root)
    if err:
        return {'contains': [], 'may_contain': [], 'error': err}
    return {'contains': sorted(contains), 'may_contain': sorted(may - contains), 'error': None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'peanuts'], 'uses': ['crust', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['Egg', 'wheat'], 'uses': ['filling', 'mystery']},
     'topping': {'allergens': ['dairy', ' sesame '], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts', 'soy'], 'may_contain': [' sesame '], 'uses': ['crust', 'filling']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['tree nuts'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['crust']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [' sesame ', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': []},
     'crust': {'allergens': ['Egg', 'soy'], 'may_contain': ['soy', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['eggs', 'tree nuts'], 'may_contain': ['Egg'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['dairy', 'soy'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'tree nuts'], 'uses': ['mystery']},
     'crust': {'allergens': ['wheat'], 'may_contain': [' sesame ', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['tree nuts', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['peanuts'], 'may_contain': ['Egg'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': ['soy'], 'may_contain': ['tree nuts', 'wheat'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['Egg'], 'uses': []},
     'filling': {'allergens': ['dairy'], 'may_contain': [' sesame '], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['tree nuts', 'Egg'], 'uses': []},
     'topping': {'allergens': [' sesame ', 'tree nuts'], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}]],
 [['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['peanuts', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': ['wheat', 'soy'], 'may_contain': [], 'uses': ['filling']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'wheat'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['peanut', 'soy', 'tree nut', 'wheat'], 'error': None, 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [' sesame '], 'may_contain': [], 'uses': ['crust']},
     'crust': {'allergens': ['Egg', 'milk'],
               'may_contain': ['milk', 'tree nuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['Egg'], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'dairy'], 'may_contain': ['Egg', 'tree nuts'], 'uses': ['filling']},
     'topping': {'allergens': ['eggs', 'tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['milk', 'wheat'], 'uses': ['sauce', 'filling']},
     'crust': {'allergens': [' sesame ', 'wheat'],
               'may_contain': ['peanuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['tree nuts', 'soy'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['peanuts'], 'uses': ['crust']},
     'topping': {'allergens': ['eggs', 'soy'], 'may_contain': ['peanuts'], 'uses': ['mystery']}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['eggs', 'soy'],
              'may_contain': ['tree nuts', 'Egg'],
              'uses': ['filling', 'topping']},
     'crust': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['milk'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': ['dairy', 'wheat'], 'uses': []},
     'sauce': {'allergens': ['soy', 'peanuts'], 'may_contain': [], 'uses': ['crust']},
     'topping': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', 'dairy'], 'uses': ['topping']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy', 'peanuts'], 'uses': []},
     'filling': {'allergens': ['Egg', 'soy'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat'], 'uses': ['filling']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]],
 [['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['wheat'], 'uses': ['sauce']},
     'crust': {'allergens': ['eggs'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [' sesame '],
               'may_contain': ['peanuts', 'tree nuts'],
               'uses': ['crust', 'mystery']},
     'topping': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['peanuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['wheat', 'tree nuts'], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['soy', 'wheat'], 'uses': ['base']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': ['soy'], 'may_contain': ['tree nuts'], 'uses': []},
     'filling': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['dairy', 'tree nuts'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'milk'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'peanut', 'sesame'], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['Egg'], 'uses': ['sauce']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': ['milk', 'dairy'], 'may_contain': ['dairy'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame ', 'peanuts'], 'may_contain': ['milk', 'soy'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['milk', 'soy']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'filling', 'topping', 'mystery']},
     'crust': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': ['topping']},
     'sauce': {'allergens': ['tree nuts', 'peanuts'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['wheat', ' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}]],
 [['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': [' sesame '], 'may_contain': ['dairy'], 'uses': ['topping', 'base', 'mystery']},
     'sauce': {'allergens': [' sesame ', 'soy'],
               'may_contain': ['soy', 'tree nuts'],
               'uses': ['crust', 'topping']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat', 'milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'sesame', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'mystery']},
     'crust': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['milk', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'soy'],
               'may_contain': ['peanuts'],
               'uses': ['crust', 'filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [' sesame '], 'uses': []},
     'crust': {'allergens': ['dairy'], 'may_contain': ['soy', 'wheat'], 'uses': ['filling']},
     'filling': {'allergens': ['soy'], 'may_contain': ['eggs', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['milk', 'soy'], 'may_contain': [' sesame '], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': ['sesame']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'crust': {'allergens': [], 'may_contain': ['tree nuts'], 'uses': ['topping', 'mystery']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk', 'peanuts'], 'may_contain': ['wheat'], 'uses': []},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk', 'Egg'], 'uses': []}},
    'base'],
   {'contains': ['peanut'], 'error': None, 'may_contain': ['egg', 'milk']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['filling']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['wheat'], 'may_contain': ['eggs'], 'uses': []}},
    'base'],
   {'contains': ['wheat'], 'error': None, 'may_contain': ['egg']}]],
 [['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['wheat'],
              'may_contain': [' sesame ', 'dairy'],
              'uses': ['sauce', 'crust', 'topping', 'mystery']},
     'crust': {'allergens': ['peanuts', ' sesame '], 'may_contain': ['eggs', 'milk'], 'uses': ['sauce']},
     'filling': {'allergens': ['peanuts'], 'may_contain': ['Egg', 'dairy'], 'uses': []},
     'sauce': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['peanuts'], 'uses': []},
     'topping': {'allergens': [' sesame '], 'may_contain': ['tree nuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts'], 'may_contain': [' sesame '], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': ['dairy', 'Egg'], 'may_contain': ['milk'], 'uses': []},
     'sauce': {'allergens': ['eggs'], 'may_contain': ['milk', 'tree nuts'], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': ['Egg'], 'may_contain': ['dairy'], 'uses': []},
     'crust': {'allergens': ['milk'], 'may_contain': ['tree nuts'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['milk'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['wheat'], 'may_contain': [], 'uses': ['crust', 'filling', 'base']},
     'topping': {'allergens': [], 'may_contain': ['Egg', ' sesame '], 'uses': ['mystery']}},
    'base'],
   {'contains': ['egg'], 'error': None, 'may_contain': ['milk']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', ' sesame '], 'uses': ['filling']},
     'crust': {'allergens': [], 'may_contain': ['peanuts', 'soy'], 'uses': ['filling', 'mystery']},
     'filling': {'allergens': ['milk', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': [' sesame '], 'may_contain': ['wheat'], 'uses': ['crust', 'topping', 'base']},
     'topping': {'allergens': [], 'may_contain': ['tree nuts', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': ['sesame', 'tree nut']}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'crust': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['dairy', 'eggs'], 'may_contain': [' sesame '], 'uses': ['topping']},
     'sauce': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk'], 'uses': ['sauce']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]]]
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
flat recipe{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}Passed
diamond sharing{'contains': [], 'error': 'cycle: c', 'may_contain': []}{'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}Failed
cycle{'contains': [], 'error': 'cycle: a', 'may_contain': []}{'contains': [], 'error': 'cycle: base', 'may_contain': []}Failed
regression: diamond versus cycle{'contains': [], 'error': 'cycle: topping', 'may_contain': []}{'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}Failed
repair check: diamond versus cycle{'contains': [], 'error': 'cycle: topping', 'may_contain': []}{'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}Failed
generated control 1{'contains': [], 'error': None, 'may_contain': []}{'contains': [], 'error': None, 'may_contain': []}Passed
generated control 2{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}Passed
generated control 3{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}Passed

SHA-256 / 09483b6d4467e0bf217875b44a142b1323166a7e048315d45af238062f383fd6

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(recipes, root):
    SYN = {'dairy': 'milk', 'peanuts': 'peanut', 'tree nuts': 'tree nut', 'eggs': 'egg'}
    def canon(a):
        a = a.strip().lower()
        return SYN.get(a, a)
    contains, may = set(), set()
    state = {}
    def visit(n):
        if n not in recipes:
            return 'unknown: ' + n
        if state.get(n) == 1:
            return 'cycle: ' + n
        if state.get(n) == 2:
            return None
        state[n] = 1
        r = recipes[n]
        contains.update(canon(a) for a in r.get('allergens', []))
        may.update(canon(a) for a in r.get('may_contain', []))
        for s in r.get('uses', []):
            e = visit(s)
            if e:
                return e
        state[n] = 2
        return None
    err = visit(root)
    if err:
        return {'contains': [], 'may_contain': [], 'error': err}
    return {'contains': sorted(contains), 'may_contain': sorted(may - contains), 'error': None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'peanuts'], 'uses': ['crust', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['Egg', 'wheat'], 'uses': ['filling', 'mystery']},
     'topping': {'allergens': ['dairy', ' sesame '], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts', 'soy'], 'may_contain': [' sesame '], 'uses': ['crust', 'filling']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['tree nuts'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['crust']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [' sesame ', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': []},
     'crust': {'allergens': ['Egg', 'soy'], 'may_contain': ['soy', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['eggs', 'tree nuts'], 'may_contain': ['Egg'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['dairy', 'soy'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['soy', 'tree nuts'], 'uses': ['mystery']},
     'crust': {'allergens': ['wheat'], 'may_contain': [' sesame ', 'milk'], 'uses': ['topping']},
     'filling': {'allergens': ['tree nuts', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['peanuts'], 'may_contain': ['Egg'], 'uses': ['filling', 'topping']},
     'topping': {'allergens': ['soy'], 'may_contain': ['tree nuts', 'wheat'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': [], 'may_contain': ['Egg'], 'uses': []},
     'filling': {'allergens': ['dairy'], 'may_contain': [' sesame '], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['tree nuts', 'Egg'], 'uses': []},
     'topping': {'allergens': [' sesame ', 'tree nuts'], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}]],
 [['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['peanuts', 'tree nuts'], 'may_contain': [], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': ['wheat', 'soy'], 'may_contain': [], 'uses': ['filling']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'wheat'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['peanut', 'soy', 'tree nut', 'wheat'], 'error': None, 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [' sesame '], 'may_contain': [], 'uses': ['crust']},
     'crust': {'allergens': ['Egg', 'milk'],
               'may_contain': ['milk', 'tree nuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['Egg'], 'uses': ['topping']},
     'sauce': {'allergens': ['soy', 'dairy'], 'may_contain': ['Egg', 'tree nuts'], 'uses': ['filling']},
     'topping': {'allergens': ['eggs', 'tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['milk', 'wheat'], 'uses': ['sauce', 'filling']},
     'crust': {'allergens': [' sesame ', 'wheat'],
               'may_contain': ['peanuts'],
               'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['tree nuts', 'soy'], 'uses': []},
     'sauce': {'allergens': [], 'may_contain': ['peanuts'], 'uses': ['crust']},
     'topping': {'allergens': ['eggs', 'soy'], 'may_contain': ['peanuts'], 'uses': ['mystery']}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['eggs', 'soy'],
              'may_contain': ['tree nuts', 'Egg'],
              'uses': ['filling', 'topping']},
     'crust': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['milk'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': ['dairy', 'wheat'], 'uses': []},
     'sauce': {'allergens': ['soy', 'peanuts'], 'may_contain': [], 'uses': ['crust']},
     'topping': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', 'dairy'], 'uses': ['topping']},
     'crust': {'allergens': ['peanuts'], 'may_contain': ['dairy', 'peanuts'], 'uses': []},
     'filling': {'allergens': ['Egg', 'soy'], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat'], 'uses': ['filling']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]],
 [['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['wheat'], 'uses': ['sauce']},
     'crust': {'allergens': ['eggs'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [' sesame '],
               'may_contain': ['peanuts', 'tree nuts'],
               'uses': ['crust', 'mystery']},
     'topping': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['peanuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['eggs'], 'may_contain': ['wheat', 'tree nuts'], 'uses': ['sauce', 'topping']},
     'crust': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['soy'], 'uses': ['topping']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': ['soy', 'wheat'], 'uses': ['base']},
     'topping': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': ['soy'], 'may_contain': ['tree nuts'], 'uses': []},
     'filling': {'allergens': ['tree nuts', 'dairy'], 'may_contain': ['dairy', 'tree nuts'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'milk'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'milk', 'peanut', 'sesame'], 'error': None, 'may_contain': []}],
  ['generated control 2',
   [{'base': {'allergens': ['tree nuts', 'Egg'], 'may_contain': ['Egg'], 'uses': ['sauce']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': ['milk', 'dairy'], 'may_contain': ['dairy'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': [' sesame ', 'peanuts'], 'may_contain': ['milk', 'soy'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'peanut', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['milk', 'soy']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'filling', 'topping', 'mystery']},
     'crust': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['soy'], 'may_contain': ['milk'], 'uses': ['topping']},
     'sauce': {'allergens': ['tree nuts', 'peanuts'], 'may_contain': [], 'uses': ['crust', 'filling']},
     'topping': {'allergens': ['wheat', ' sesame '], 'may_contain': ['milk'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}]],
 [['unknown sub', [{'base': {'uses': ['ghost']}}, 'base'],
   {'contains': [], 'error': 'unknown: ghost', 'may_contain': []}],
  ['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': [' sesame '], 'may_contain': ['dairy'], 'uses': ['topping', 'base', 'mystery']},
     'sauce': {'allergens': [' sesame ', 'soy'],
               'may_contain': ['soy', 'tree nuts'],
               'uses': ['crust', 'topping']},
     'topping': {'allergens': ['eggs'], 'may_contain': ['wheat', 'milk'], 'uses': []}},
    'base'],
   {'contains': ['egg', 'sesame', 'soy'], 'error': None, 'may_contain': ['milk', 'tree nut', 'wheat']}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['sauce', 'mystery']},
     'crust': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': [], 'may_contain': ['milk', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg', 'soy'],
               'may_contain': ['peanuts'],
               'uses': ['crust', 'filling', 'topping']},
     'topping': {'allergens': [], 'may_contain': ['dairy'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['generated control 1',
   [{'base': {'allergens': [], 'may_contain': [' sesame '], 'uses': []},
     'crust': {'allergens': ['dairy'], 'may_contain': ['soy', 'wheat'], 'uses': ['filling']},
     'filling': {'allergens': ['soy'], 'may_contain': ['eggs', 'soy'], 'uses': []},
     'sauce': {'allergens': ['Egg'], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['milk', 'soy'], 'may_contain': [' sesame '], 'uses': []}},
    'base'],
   {'contains': [], 'error': None, 'may_contain': ['sesame']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'crust': {'allergens': [], 'may_contain': ['tree nuts'], 'uses': ['topping', 'mystery']},
     'filling': {'allergens': [], 'may_contain': [], 'uses': ['topping']},
     'sauce': {'allergens': ['milk', 'peanuts'], 'may_contain': ['wheat'], 'uses': []},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk', 'Egg'], 'uses': []}},
    'base'],
   {'contains': ['peanut'], 'error': None, 'may_contain': ['egg', 'milk']}],
  ['generated control 3',
   [{'base': {'allergens': [], 'may_contain': [], 'uses': ['filling']},
     'crust': {'allergens': ['tree nuts'], 'may_contain': [], 'uses': []},
     'filling': {'allergens': [], 'may_contain': ['wheat', 'eggs'], 'uses': ['topping']},
     'sauce': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'base']},
     'topping': {'allergens': ['wheat'], 'may_contain': ['eggs'], 'uses': []}},
    'base'],
   {'contains': ['wheat'], 'error': None, 'may_contain': ['egg']}]],
 [['flat recipe', [{'base': {'allergens': ['milk'], 'may_contain': ['soy'], 'uses': []}}, 'base'],
   {'contains': ['milk'], 'error': None, 'may_contain': ['soy']}],
  ['diamond sharing',
   [{'a': {'allergens': ['wheat'], 'uses': ['c']},
     'b': {'allergens': [], 'uses': ['c']},
     'base': {'allergens': [], 'uses': ['a', 'b']},
     'c': {'allergens': ['Dairy'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}],
  ['cycle', [{'a': {'uses': ['base']}, 'base': {'uses': ['a']}}, 'base'],
   {'contains': [], 'error': 'cycle: base', 'may_contain': []}],
  ['regression: diamond versus cycle',
   [{'base': {'allergens': ['wheat'],
              'may_contain': [' sesame ', 'dairy'],
              'uses': ['sauce', 'crust', 'topping', 'mystery']},
     'crust': {'allergens': ['peanuts', ' sesame '], 'may_contain': ['eggs', 'milk'], 'uses': ['sauce']},
     'filling': {'allergens': ['peanuts'], 'may_contain': ['Egg', 'dairy'], 'uses': []},
     'sauce': {'allergens': ['soy', 'tree nuts'], 'may_contain': ['peanuts'], 'uses': []},
     'topping': {'allergens': [' sesame '], 'may_contain': ['tree nuts'], 'uses': []}},
    'base'],
   {'contains': [], 'error': 'unknown: mystery', 'may_contain': []}],
  ['repair check: diamond versus cycle',
   [{'base': {'allergens': ['tree nuts'], 'may_contain': [' sesame '], 'uses': ['sauce', 'crust']},
     'crust': {'allergens': [], 'may_contain': ['eggs'], 'uses': ['topping']},
     'filling': {'allergens': ['dairy', 'Egg'], 'may_contain': ['milk'], 'uses': []},
     'sauce': {'allergens': ['eggs'], 'may_contain': ['milk', 'tree nuts'], 'uses': ['topping']},
     'topping': {'allergens': [], 'may_contain': [], 'uses': []}},
    'base'],
   {'contains': ['egg', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}],
  ['generated control 1',
   [{'base': {'allergens': ['Egg'], 'may_contain': ['dairy'], 'uses': []},
     'crust': {'allergens': ['milk'], 'may_contain': ['tree nuts'], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['milk'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': ['wheat'], 'may_contain': [], 'uses': ['crust', 'filling', 'base']},
     'topping': {'allergens': [], 'may_contain': ['Egg', ' sesame '], 'uses': ['mystery']}},
    'base'],
   {'contains': ['egg'], 'error': None, 'may_contain': ['milk']}],
  ['generated control 2',
   [{'base': {'allergens': [], 'may_contain': ['tree nuts', ' sesame '], 'uses': ['filling']},
     'crust': {'allergens': [], 'may_contain': ['peanuts', 'soy'], 'uses': ['filling', 'mystery']},
     'filling': {'allergens': ['milk', 'wheat'], 'may_contain': [], 'uses': []},
     'sauce': {'allergens': [' sesame '], 'may_contain': ['wheat'], 'uses': ['crust', 'topping', 'base']},
     'topping': {'allergens': [], 'may_contain': ['tree nuts', 'peanuts'], 'uses': []}},
    'base'],
   {'contains': ['milk', 'wheat'], 'error': None, 'may_contain': ['sesame', 'tree nut']}],
  ['generated control 3',
   [{'base': {'allergens': ['dairy'], 'may_contain': ['eggs'], 'uses': ['filling', 'topping']},
     'crust': {'allergens': [], 'may_contain': [], 'uses': ['filling', 'topping']},
     'filling': {'allergens': ['dairy', 'eggs'], 'may_contain': [' sesame '], 'uses': ['topping']},
     'sauce': {'allergens': ['peanuts'], 'may_contain': [], 'uses': ['topping']},
     'topping': {'allergens': ['peanuts'], 'may_contain': ['milk'], 'uses': ['sauce']}},
    'base'],
   {'contains': [], 'error': 'cycle: topping', 'may_contain': []}]]]
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
flat recipe{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}{'contains': ['milk'], 'error': None, 'may_contain': ['soy']}Passed
diamond sharing{'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}{'contains': ['milk', 'wheat'], 'error': None, 'may_contain': []}Passed
cycle{'contains': [], 'error': 'cycle: base', 'may_contain': []}{'contains': [], 'error': 'cycle: base', 'may_contain': []}Passed
regression: diamond versus cycle{'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}{'contains': ['milk', 'sesame'], 'error': None, 'may_contain': ['peanut', 'soy']}Passed
repair check: diamond versus cycle{'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}{'contains': ['egg', 'peanut', 'soy', 'tree nut'], 'error': None, 'may_contain': ['milk', 'sesame']}Passed
generated control 1{'contains': [], 'error': None, 'may_contain': []}{'contains': [], 'error': None, 'may_contain': []}Passed
generated control 2{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}{'contains': [], 'error': 'unknown: mystery', 'may_contain': []}Passed
generated control 3{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}{'contains': ['milk', 'sesame', 'tree nut'], 'error': None, 'may_contain': ['egg']}Passed

SHA-256 / c2c70ef03cf0aa0efd05d831eae006cebbe694a01c319b52c0d0655384381293

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

Case digest / d3c7304a77171a01ed2210f945e69437c6fca616e470af7aacb4d64afd4aa408