FA-97311 / Recipe scaling and nutrition / Open access
Backward recipe step scheduler: unknown dependency check · case 01
A step depending on a missing "shop" step is scheduled as if the dependency were satisfied.
ROOT CAUSE
Unknown dependencies are skipped instead of reported.
VERIFIED REPAIR
Return an error for any unknown dependency.
Unsuccessful approach: Checking only the first step misses unknown dependencies elsewhere.
Case contract
Steps [name, minutes, depends_on]; a step must finish before any step depending on it starts. Latest start = min(latest start of dependents, serve time) - minutes. Unknown dependency -> "error: unknown step X"; a cycle -> "error: cycle". Serve "HH:MM"; starts print as "HH:MM" modulo 24h (previous day wraps). Output [[name, time]] sorted by absolute start then name.
Why this case matters
Dinner-party and restaurant prep planners schedule long marinades and roasts backward from service.
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(steps, serve):
by = {s[0]: s for s in steps}
for s in steps:
for d in s[2]:
if d not in by:
continue
h, m = serve.split(':')
T = int(h) * 60 + int(m)
latest = {}
visiting = set()
def ls(n):
if n in latest:
return latest[n]
if n in visiting:
return None
visiting.add(n)
finish = T
for s in steps:
if n in s[2]:
v = ls(s[0])
if v is None:
return None
finish = min(finish, v)
visiting.discard(n)
latest[n] = finish - by[n][1]
return latest[n]
rows = []
for s in steps:
v = ls(s[0])
if v is None:
return 'error: cycle'
rows.append((v, s[0]))
rows.sort()
return [[n, '%02d:%02d' % divmod(v % 1440, 60)] for v, n in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['marinate', 45, []], ['roast', 5, ['prep']], ['prep', 5, ['shop']]], '02:00'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 45, []], ['sauce', 5, ['prep', 'marinate']], ['roast', 240, []], ['marinate', 10, []],
['rest', 45, ['sauce']], ['prep', 240, ['shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 5, []], ['marinate', 10, []], ['prep', 90, []]], '18:30'],
[['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']]],
['generated control 2', [[['marinate', 240, ['prep']], ['roast', 30, ['prep']], ['prep', 45, []]], '01:15'],
[['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']]],
['generated control 3',
[[['rest', 45, ['prep', 'sauce']], ['sauce', 90, ['marinate', 'roast']], ['prep', 240, []],
['marinate', 45, []], ['roast', 45, ['marinate']]],
'12:00'],
[['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']]]],
[['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['regression: unknown dependency check',
[[['prep', 15, ['shop']], ['sauce', 5, ['roast']], ['roast', 5, ['prep', 'marinate']],
['marinate', 45, []]],
'19:45'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['marinate', 10, []], ['roast', 10, ['prep']], ['rest', 5, ['roast', 'sauce']], ['prep', 90, []],
['sauce', 30, ['prep', 'roast', 'shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 240, ['prep']], ['prep', 10, []], ['marinate', 10, []]], '02:00'],
[['prep', '21:50'], ['roast', '22:00'], ['marinate', '01:50']]],
['generated control 2',
[[['sauce', 15, ['roast']], ['roast', 45, ['prep']], ['rest', 10, []], ['marinate', 90, ['prep']],
['prep', 45, []]],
'00:30'],
[['prep', '22:15'], ['marinate', '23:00'], ['roast', '23:30'], ['sauce', '00:15'], ['rest', '00:20']]],
['generated control 3', [[['roast', 90, []], ['marinate', 10, ['prep']], ['prep', 45, []]], '12:00'],
[['roast', '10:30'], ['prep', '11:05'], ['marinate', '11:50']]]],
[['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['regression: unknown dependency check',
[[['sauce', 90, ['prep']], ['prep', 45, []], ['rest', 15, ['prep', 'sauce']],
['roast', 10, ['prep', 'marinate', 'shop']], ['marinate', 30, ['prep']]],
'01:15'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 15, ['marinate', 'sauce']], ['rest', 30, ['prep', 'marinate', 'sauce']],
['sauce', 10, ['marinate']], ['roast', 15, ['marinate']], ['marinate', 10, ['prep', 'shop']],
['prep', 45, ['plate']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['rest', 240, ['prep', 'sauce']], ['roast', 10, ['prep', 'marinate']], ['sauce', 90, ['prep']],
['prep', 30, ['rest']], ['marinate', 15, []]],
'02:00'],
'error: cycle'],
['generated control 2',
[[['prep', 45, []], ['marinate', 10, []], ['roast', 10, []], ['sauce', 5, []]], '00:30'],
[['prep', '23:45'], ['marinate', '00:20'], ['roast', '00:20'], ['sauce', '00:25']]],
['generated control 3',
[[['prep', 5, []], ['marinate', 240, ['prep']], ['roast', 5, []], ['sauce', 30, ['prep', 'roast']],
['rest', 45, ['sauce']]],
'01:15'],
[['prep', '21:10'], ['marinate', '21:15'], ['roast', '23:55'], ['sauce', '00:00'], ['rest', '00:30']]]],
[['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['regression: unknown dependency check',
[[['roast', 30, ['prep', 'marinate']], ['sauce', 10, ['prep', 'roast']], ['marinate', 30, []],
['rest', 45, ['prep', 'marinate']], ['plate', 45, ['marinate', 'sauce', 'shop']], ['prep', 45, []]],
'00:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 45, ['prep', 'roast']], ['plate', 90, ['prep', 'rest', 'shop']], ['roast', 30, []],
['rest', 240, []], ['prep', 45, []], ['marinate', 90, ['prep']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['sauce', 90, ['prep', 'marinate', 'roast']], ['roast', 10, ['marinate']], ['prep', 10, []],
['rest', 30, []], ['marinate', 5, []]],
'19:45'],
[['marinate', '18:00'], ['prep', '18:05'], ['roast', '18:05'], ['sauce', '18:15'], ['rest', '19:15']]],
['generated control 2',
[[['plate', 10, ['marinate']], ['sauce', 30, ['prep', 'marinate']], ['roast', 90, []], ['prep', 10, []],
['marinate', 90, ['prep']], ['rest', 240, ['sauce']]],
'12:00'],
[['prep', '05:50'], ['marinate', '06:00'], ['sauce', '07:30'], ['rest', '08:00'], ['roast', '10:30'],
['plate', '11:50']]],
['generated control 3', [[['roast', 240, []], ['marinate', 90, []], ['prep', 5, []]], '18:30'],
[['roast', '14:30'], ['marinate', '17:00'], ['prep', '18:25']]]],
[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['sauce', 30, ['prep', 'roast']], ['prep', 240, ['shop']], ['roast', 5, ['prep', 'marinate']],
['plate', 30, ['prep', 'sauce']], ['marinate', 10, ['prep']], ['rest', 45, ['marinate']]],
'18:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 5, ['roast']], ['prep', 90, []], ['rest', 45, ['prep']], ['marinate', 15, ['prep']],
['plate', 45, ['shop']], ['roast', 30, ['prep']]],
'18:30'],
'error: unknown step shop'],
['generated control 1', [[['marinate', 30, []], ['prep', 15, []], ['roast', 45, []]], '18:30'],
[['roast', '17:45'], ['marinate', '18:00'], ['prep', '18:15']]],
['generated control 2',
[[['marinate', 10, []], ['prep', 30, []], ['rest', 10, []], ['plate', 10, ['prep', 'sauce']],
['roast', 10, []], ['sauce', 10, ['prep', 'marinate']]],
'01:15'],
[['prep', '00:25'], ['marinate', '00:45'], ['sauce', '00:55'], ['plate', '01:05'], ['rest', '01:05'],
['roast', '01:05']]],
['generated control 3',
[[['roast', 15, ['prep', 'marinate']], ['marinate', 5, []], ['prep', 90, []],
['sauce', 240, ['marinate', 'roast']]],
'02:00'],
[['prep', '20:15'], ['marinate', '21:40'], ['roast', '21:45'], ['sauce', '22:00']]]]]
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 |
|---|---|---|---|
| chain | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | Passed |
| overnight marinade | [['marinate', '03:40'], ['grill', '11:40']] | [['marinate', '03:40'], ['grill', '11:40']] | Passed |
| cycle | error: cycle | error: cycle | Passed |
| regression: unknown dependency check | [['marinate', '01:15'], ['prep', '01:50'], ['roast', '01:55']] | error: unknown step shop | Failed |
| repair check: unknown dependency check | [['prep', '07:10'], ['roast', '08:00'], ['marinate', '11:00'], ['sauce', '11:10'], ['plate', '11:15'], ['rest', '11:15']] | error: unknown step shop | Failed |
| generated control 1 | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | Passed |
| generated control 2 | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | Passed |
| generated control 3 | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | Passed |
SHA-256 / 95055c08d7af3b6e1a4c0a081e7133c29dcf62e623552bc2a8a3f57e06a9387c
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(steps, serve):
by = {s[0]: s for s in steps}
for s in steps:
for d in s[2]:
if d not in by and s is steps[0]:
return 'error: unknown step ' + d
h, m = serve.split(':')
T = int(h) * 60 + int(m)
latest = {}
visiting = set()
def ls(n):
if n in latest:
return latest[n]
if n in visiting:
return None
visiting.add(n)
finish = T
for s in steps:
if n in s[2]:
v = ls(s[0])
if v is None:
return None
finish = min(finish, v)
visiting.discard(n)
latest[n] = finish - by[n][1]
return latest[n]
rows = []
for s in steps:
v = ls(s[0])
if v is None:
return 'error: cycle'
rows.append((v, s[0]))
rows.sort()
return [[n, '%02d:%02d' % divmod(v % 1440, 60)] for v, n in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['marinate', 45, []], ['roast', 5, ['prep']], ['prep', 5, ['shop']]], '02:00'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 45, []], ['sauce', 5, ['prep', 'marinate']], ['roast', 240, []], ['marinate', 10, []],
['rest', 45, ['sauce']], ['prep', 240, ['shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 5, []], ['marinate', 10, []], ['prep', 90, []]], '18:30'],
[['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']]],
['generated control 2', [[['marinate', 240, ['prep']], ['roast', 30, ['prep']], ['prep', 45, []]], '01:15'],
[['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']]],
['generated control 3',
[[['rest', 45, ['prep', 'sauce']], ['sauce', 90, ['marinate', 'roast']], ['prep', 240, []],
['marinate', 45, []], ['roast', 45, ['marinate']]],
'12:00'],
[['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']]]],
[['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['regression: unknown dependency check',
[[['prep', 15, ['shop']], ['sauce', 5, ['roast']], ['roast', 5, ['prep', 'marinate']],
['marinate', 45, []]],
'19:45'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['marinate', 10, []], ['roast', 10, ['prep']], ['rest', 5, ['roast', 'sauce']], ['prep', 90, []],
['sauce', 30, ['prep', 'roast', 'shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 240, ['prep']], ['prep', 10, []], ['marinate', 10, []]], '02:00'],
[['prep', '21:50'], ['roast', '22:00'], ['marinate', '01:50']]],
['generated control 2',
[[['sauce', 15, ['roast']], ['roast', 45, ['prep']], ['rest', 10, []], ['marinate', 90, ['prep']],
['prep', 45, []]],
'00:30'],
[['prep', '22:15'], ['marinate', '23:00'], ['roast', '23:30'], ['sauce', '00:15'], ['rest', '00:20']]],
['generated control 3', [[['roast', 90, []], ['marinate', 10, ['prep']], ['prep', 45, []]], '12:00'],
[['roast', '10:30'], ['prep', '11:05'], ['marinate', '11:50']]]],
[['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['regression: unknown dependency check',
[[['sauce', 90, ['prep']], ['prep', 45, []], ['rest', 15, ['prep', 'sauce']],
['roast', 10, ['prep', 'marinate', 'shop']], ['marinate', 30, ['prep']]],
'01:15'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 15, ['marinate', 'sauce']], ['rest', 30, ['prep', 'marinate', 'sauce']],
['sauce', 10, ['marinate']], ['roast', 15, ['marinate']], ['marinate', 10, ['prep', 'shop']],
['prep', 45, ['plate']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['rest', 240, ['prep', 'sauce']], ['roast', 10, ['prep', 'marinate']], ['sauce', 90, ['prep']],
['prep', 30, ['rest']], ['marinate', 15, []]],
'02:00'],
'error: cycle'],
['generated control 2',
[[['prep', 45, []], ['marinate', 10, []], ['roast', 10, []], ['sauce', 5, []]], '00:30'],
[['prep', '23:45'], ['marinate', '00:20'], ['roast', '00:20'], ['sauce', '00:25']]],
['generated control 3',
[[['prep', 5, []], ['marinate', 240, ['prep']], ['roast', 5, []], ['sauce', 30, ['prep', 'roast']],
['rest', 45, ['sauce']]],
'01:15'],
[['prep', '21:10'], ['marinate', '21:15'], ['roast', '23:55'], ['sauce', '00:00'], ['rest', '00:30']]]],
[['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['regression: unknown dependency check',
[[['roast', 30, ['prep', 'marinate']], ['sauce', 10, ['prep', 'roast']], ['marinate', 30, []],
['rest', 45, ['prep', 'marinate']], ['plate', 45, ['marinate', 'sauce', 'shop']], ['prep', 45, []]],
'00:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 45, ['prep', 'roast']], ['plate', 90, ['prep', 'rest', 'shop']], ['roast', 30, []],
['rest', 240, []], ['prep', 45, []], ['marinate', 90, ['prep']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['sauce', 90, ['prep', 'marinate', 'roast']], ['roast', 10, ['marinate']], ['prep', 10, []],
['rest', 30, []], ['marinate', 5, []]],
'19:45'],
[['marinate', '18:00'], ['prep', '18:05'], ['roast', '18:05'], ['sauce', '18:15'], ['rest', '19:15']]],
['generated control 2',
[[['plate', 10, ['marinate']], ['sauce', 30, ['prep', 'marinate']], ['roast', 90, []], ['prep', 10, []],
['marinate', 90, ['prep']], ['rest', 240, ['sauce']]],
'12:00'],
[['prep', '05:50'], ['marinate', '06:00'], ['sauce', '07:30'], ['rest', '08:00'], ['roast', '10:30'],
['plate', '11:50']]],
['generated control 3', [[['roast', 240, []], ['marinate', 90, []], ['prep', 5, []]], '18:30'],
[['roast', '14:30'], ['marinate', '17:00'], ['prep', '18:25']]]],
[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['sauce', 30, ['prep', 'roast']], ['prep', 240, ['shop']], ['roast', 5, ['prep', 'marinate']],
['plate', 30, ['prep', 'sauce']], ['marinate', 10, ['prep']], ['rest', 45, ['marinate']]],
'18:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 5, ['roast']], ['prep', 90, []], ['rest', 45, ['prep']], ['marinate', 15, ['prep']],
['plate', 45, ['shop']], ['roast', 30, ['prep']]],
'18:30'],
'error: unknown step shop'],
['generated control 1', [[['marinate', 30, []], ['prep', 15, []], ['roast', 45, []]], '18:30'],
[['roast', '17:45'], ['marinate', '18:00'], ['prep', '18:15']]],
['generated control 2',
[[['marinate', 10, []], ['prep', 30, []], ['rest', 10, []], ['plate', 10, ['prep', 'sauce']],
['roast', 10, []], ['sauce', 10, ['prep', 'marinate']]],
'01:15'],
[['prep', '00:25'], ['marinate', '00:45'], ['sauce', '00:55'], ['plate', '01:05'], ['rest', '01:05'],
['roast', '01:05']]],
['generated control 3',
[[['roast', 15, ['prep', 'marinate']], ['marinate', 5, []], ['prep', 90, []],
['sauce', 240, ['marinate', 'roast']]],
'02:00'],
[['prep', '20:15'], ['marinate', '21:40'], ['roast', '21:45'], ['sauce', '22:00']]]]]
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 |
|---|---|---|---|
| chain | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | Passed |
| overnight marinade | [['marinate', '03:40'], ['grill', '11:40']] | [['marinate', '03:40'], ['grill', '11:40']] | Passed |
| cycle | error: cycle | error: cycle | Passed |
| regression: unknown dependency check | [['marinate', '01:15'], ['prep', '01:50'], ['roast', '01:55']] | error: unknown step shop | Failed |
| repair check: unknown dependency check | [['prep', '07:10'], ['roast', '08:00'], ['marinate', '11:00'], ['sauce', '11:10'], ['plate', '11:15'], ['rest', '11:15']] | error: unknown step shop | Failed |
| generated control 1 | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | Passed |
| generated control 2 | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | Passed |
| generated control 3 | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | Passed |
SHA-256 / 0aa4f4c26cdfd9aa6ce7667d02c9ab0f1fb2832d76a01d8ee907b3eb93b33ec1
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(steps, serve):
by = {s[0]: s for s in steps}
for s in steps:
for d in s[2]:
if d not in by:
return 'error: unknown step ' + d
h, m = serve.split(':')
T = int(h) * 60 + int(m)
latest = {}
visiting = set()
def ls(n):
if n in latest:
return latest[n]
if n in visiting:
return None
visiting.add(n)
finish = T
for s in steps:
if n in s[2]:
v = ls(s[0])
if v is None:
return None
finish = min(finish, v)
visiting.discard(n)
latest[n] = finish - by[n][1]
return latest[n]
rows = []
for s in steps:
v = ls(s[0])
if v is None:
return 'error: cycle'
rows.append((v, s[0]))
rows.sort()
return [[n, '%02d:%02d' % divmod(v % 1440, 60)] for v, n in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['marinate', 45, []], ['roast', 5, ['prep']], ['prep', 5, ['shop']]], '02:00'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 45, []], ['sauce', 5, ['prep', 'marinate']], ['roast', 240, []], ['marinate', 10, []],
['rest', 45, ['sauce']], ['prep', 240, ['shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 5, []], ['marinate', 10, []], ['prep', 90, []]], '18:30'],
[['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']]],
['generated control 2', [[['marinate', 240, ['prep']], ['roast', 30, ['prep']], ['prep', 45, []]], '01:15'],
[['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']]],
['generated control 3',
[[['rest', 45, ['prep', 'sauce']], ['sauce', 90, ['marinate', 'roast']], ['prep', 240, []],
['marinate', 45, []], ['roast', 45, ['marinate']]],
'12:00'],
[['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']]]],
[['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['regression: unknown dependency check',
[[['prep', 15, ['shop']], ['sauce', 5, ['roast']], ['roast', 5, ['prep', 'marinate']],
['marinate', 45, []]],
'19:45'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['marinate', 10, []], ['roast', 10, ['prep']], ['rest', 5, ['roast', 'sauce']], ['prep', 90, []],
['sauce', 30, ['prep', 'roast', 'shop']]],
'12:00'],
'error: unknown step shop'],
['generated control 1', [[['roast', 240, ['prep']], ['prep', 10, []], ['marinate', 10, []]], '02:00'],
[['prep', '21:50'], ['roast', '22:00'], ['marinate', '01:50']]],
['generated control 2',
[[['sauce', 15, ['roast']], ['roast', 45, ['prep']], ['rest', 10, []], ['marinate', 90, ['prep']],
['prep', 45, []]],
'00:30'],
[['prep', '22:15'], ['marinate', '23:00'], ['roast', '23:30'], ['sauce', '00:15'], ['rest', '00:20']]],
['generated control 3', [[['roast', 90, []], ['marinate', 10, ['prep']], ['prep', 45, []]], '12:00'],
[['roast', '10:30'], ['prep', '11:05'], ['marinate', '11:50']]]],
[['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['regression: unknown dependency check',
[[['sauce', 90, ['prep']], ['prep', 45, []], ['rest', 15, ['prep', 'sauce']],
['roast', 10, ['prep', 'marinate', 'shop']], ['marinate', 30, ['prep']]],
'01:15'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['plate', 15, ['marinate', 'sauce']], ['rest', 30, ['prep', 'marinate', 'sauce']],
['sauce', 10, ['marinate']], ['roast', 15, ['marinate']], ['marinate', 10, ['prep', 'shop']],
['prep', 45, ['plate']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['rest', 240, ['prep', 'sauce']], ['roast', 10, ['prep', 'marinate']], ['sauce', 90, ['prep']],
['prep', 30, ['rest']], ['marinate', 15, []]],
'02:00'],
'error: cycle'],
['generated control 2',
[[['prep', 45, []], ['marinate', 10, []], ['roast', 10, []], ['sauce', 5, []]], '00:30'],
[['prep', '23:45'], ['marinate', '00:20'], ['roast', '00:20'], ['sauce', '00:25']]],
['generated control 3',
[[['prep', 5, []], ['marinate', 240, ['prep']], ['roast', 5, []], ['sauce', 30, ['prep', 'roast']],
['rest', 45, ['sauce']]],
'01:15'],
[['prep', '21:10'], ['marinate', '21:15'], ['roast', '23:55'], ['sauce', '00:00'], ['rest', '00:30']]]],
[['unknown dependency', [[['a', 5, ['shop']]], '18:00'], 'error: unknown step shop'],
['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['regression: unknown dependency check',
[[['roast', 30, ['prep', 'marinate']], ['sauce', 10, ['prep', 'roast']], ['marinate', 30, []],
['rest', 45, ['prep', 'marinate']], ['plate', 45, ['marinate', 'sauce', 'shop']], ['prep', 45, []]],
'00:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 45, ['prep', 'roast']], ['plate', 90, ['prep', 'rest', 'shop']], ['roast', 30, []],
['rest', 240, []], ['prep', 45, []], ['marinate', 90, ['prep']]],
'02:00'],
'error: unknown step shop'],
['generated control 1',
[[['sauce', 90, ['prep', 'marinate', 'roast']], ['roast', 10, ['marinate']], ['prep', 10, []],
['rest', 30, []], ['marinate', 5, []]],
'19:45'],
[['marinate', '18:00'], ['prep', '18:05'], ['roast', '18:05'], ['sauce', '18:15'], ['rest', '19:15']]],
['generated control 2',
[[['plate', 10, ['marinate']], ['sauce', 30, ['prep', 'marinate']], ['roast', 90, []], ['prep', 10, []],
['marinate', 90, ['prep']], ['rest', 240, ['sauce']]],
'12:00'],
[['prep', '05:50'], ['marinate', '06:00'], ['sauce', '07:30'], ['rest', '08:00'], ['roast', '10:30'],
['plate', '11:50']]],
['generated control 3', [[['roast', 240, []], ['marinate', 90, []], ['prep', 5, []]], '18:30'],
[['roast', '14:30'], ['marinate', '17:00'], ['prep', '18:25']]]],
[['chain', [[['prep', 10, []], ['roast', 90, ['prep']], ['rest', 15, ['roast']]], '18:30'],
[['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']]],
['overnight marinade', [[['marinate', 480, []], ['grill', 20, ['marinate']]], '12:00'],
[['marinate', '03:40'], ['grill', '11:40']]],
['cycle', [[['a', 5, ['b']], ['b', 5, ['a']]], '18:00'], 'error: cycle'],
['regression: unknown dependency check',
[[['sauce', 30, ['prep', 'roast']], ['prep', 240, ['shop']], ['roast', 5, ['prep', 'marinate']],
['plate', 30, ['prep', 'sauce']], ['marinate', 10, ['prep']], ['rest', 45, ['marinate']]],
'18:30'],
'error: unknown step shop'],
['repair check: unknown dependency check',
[[['sauce', 5, ['roast']], ['prep', 90, []], ['rest', 45, ['prep']], ['marinate', 15, ['prep']],
['plate', 45, ['shop']], ['roast', 30, ['prep']]],
'18:30'],
'error: unknown step shop'],
['generated control 1', [[['marinate', 30, []], ['prep', 15, []], ['roast', 45, []]], '18:30'],
[['roast', '17:45'], ['marinate', '18:00'], ['prep', '18:15']]],
['generated control 2',
[[['marinate', 10, []], ['prep', 30, []], ['rest', 10, []], ['plate', 10, ['prep', 'sauce']],
['roast', 10, []], ['sauce', 10, ['prep', 'marinate']]],
'01:15'],
[['prep', '00:25'], ['marinate', '00:45'], ['sauce', '00:55'], ['plate', '01:05'], ['rest', '01:05'],
['roast', '01:05']]],
['generated control 3',
[[['roast', 15, ['prep', 'marinate']], ['marinate', 5, []], ['prep', 90, []],
['sauce', 240, ['marinate', 'roast']]],
'02:00'],
[['prep', '20:15'], ['marinate', '21:40'], ['roast', '21:45'], ['sauce', '22:00']]]]]
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 |
|---|---|---|---|
| chain | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | [['prep', '16:35'], ['roast', '16:45'], ['rest', '18:15']] | Passed |
| overnight marinade | [['marinate', '03:40'], ['grill', '11:40']] | [['marinate', '03:40'], ['grill', '11:40']] | Passed |
| cycle | error: cycle | error: cycle | Passed |
| regression: unknown dependency check | error: unknown step shop | error: unknown step shop | Passed |
| repair check: unknown dependency check | error: unknown step shop | error: unknown step shop | Passed |
| generated control 1 | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | [['prep', '17:00'], ['marinate', '18:20'], ['roast', '18:25']] | Passed |
| generated control 2 | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | [['prep', '20:30'], ['marinate', '21:15'], ['roast', '00:45']] | Passed |
| generated control 3 | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | [['prep', '07:15'], ['marinate', '08:15'], ['roast', '09:00'], ['sauce', '09:45'], ['rest', '11:15']] | Passed |
SHA-256 / e787a02d8a61647df2e246f322de2e8c47114cabe0dee1cf754c065dc6d0a984
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.964311+00:00.
Case digest / 1bc92afcb31ac67b421d2ce2aeedf857ff766bb38e4d844f725a7c3a38e9f1a9