broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = offset,max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(-1,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Negative braille pan offsets index from the document end.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width-1]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Braille viewport capacity is treated as an absolute endpoint.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [(c if c else ' ') for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('*' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Protected content tokens leak through the braille bridge.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else c) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else '')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Empty braille cells disappear instead of occupying a display slot.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[i,i+1] for i,_ in enumerate(window)]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,s+1] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Braille routing ranges are replaced by cell display indices.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if -len(window) <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if -1 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Negative routing coordinates select the last displayed cell.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = cells[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = cells[min(route,len(cells)-1)]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Routing offsets are incorrectly translated as document cell offsets.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if True: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable or c: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Read-only braille cells accept a text routing position.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [e,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,s]
    return [contents,ranges,routed,offset>0,offset+len(window)<len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Routing collapses an expanded contraction to its final source character.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+len(window)<=len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    cells,offset,width,route = data
    offset,width = max(0,offset),max(0,width)
    window = cells[offset:offset+width]
    contents = [('•' if c == 'SECRET' else (c if c else ' ')) for s,e,c,editable in window]
    ranges = [[s,e] for s,e,c,editable in window]
    routed = None
    if 0 <= route < len(window):
        s,e,c,editable = window[route]
        if editable: routed = [s,e]
    return [contents,ranges,routed,offset>0,offset+width<=len(cells)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[[0,N,'ab',True],[N,N+2,'SECRET',False],[N+2,N+2,'',True]],1,2,1],), [['•',' '],[[N,N+2],[N+2,N+2]],[N+2,N+2],True,False])
check('contract fixture 2', solve([[[0,2,'ab',True],[2,3,'c',True],[3,4,'d',True]],0,2,0],), [['ab','c'],[[0,2],[2,3]],[0,2],False,True])
check('contract fixture 3', solve([[[0,1,'x',False]],0,1,0],), [['x'],[[0,1]],None,False,False])
check('contract fixture 4', solve([[[0,1,'x',True]],0,1,-1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 5', solve([[[0,1,'x',True]],0,1,1],), [['x'],[[0,1]],None,False,False])
check('contract fixture 6', solve([[[0,1,'x',True]],-2,0,0],), [[],[],None,False,True])
check('contract fixture 7', solve([[[0,1,'a',True],[1,2,'b',True]],-1,1,0],), [['a'],[[0,1]],[0,1],False,True])
check('contract fixture 8', solve([[],0,4,0],), [[],[],None,False,False])
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)

prompt:
Braille viewport end treats an exact final cell as more content.

Input [cells,offset,width,route] where cells [source_start,source_end,content,editable]. Clip display window by nonnegative offset and width. Each cell has one display position regardless of content length. Routing uses a zero-based position inside displayed cells; return None if outside window or cell not editable, otherwise [source_start,source_end]. Display contents replace empty cell content with a space; protected content (exact token SECRET) displays a bullet. Return [display,source_ranges,route_result,has_previous,has_next]. Source ranges preserve zero-width insertion cells.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'label_for','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'described_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Label relationships generate the wrong inverse semantic.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'labelled_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'description_for','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Description providers are exposed as accessible names.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controls','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'details_for','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Controlled objects report forward control instead of controller relation.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'described_by'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Detail providers lose the inverse consumer relationship.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,source]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [inverse[kind],target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Forward relationships point back to their own source.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],target]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [kind,source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Inverse relationships retain the original target endpoint.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if True: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if not result[source] or result[source][-1] != backward: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Repeated declarations duplicate forward relation descriptors.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if True: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if not result[target] or result[target][-1] != forward: result[target].append(backward)
    return [[node,result[node]] for node in nodes]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Repeated declarations duplicate inverse relation descriptors.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in nodes if result[node]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    nodes,relations = data
    inverse = {'label_for':'labelled_by','description_for':'described_by','controls':'controlled_by','details':'details_for'}
    result = {node:[] for node in nodes}
    for source,kind,target in relations:
        if kind not in inverse or source not in result or target not in result or source == target: continue
        forward = [kind,target]
        backward = [inverse[kind],source]
        if forward not in result[source]: result[source].append(forward)
        if backward not in result[target]: result[target].append(backward)
    return [[node,result[node]] for node in sorted(nodes)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','b',str(N),'alone'],[['a','label_for','b'],['a','description_for','b'],['b','controls',str(N)],['a','details',str(N)]]],), [['a',[['label_for','b'],['description_for','b'],['details',str(N)]]],['b',[['labelled_by','a'],['described_by','a'],['controls',str(N)]]],[str(N),[['controlled_by','b'],['details_for','a']]],['alone',[]]])
check('contract fixture 2', solve([['a','b'],[['a','controls','b'],['b','controls','a']]],), [['a',[['controls','b'],['controlled_by','b']]],['b',[['controlled_by','a'],['controls','a']]]])
check('contract fixture 3', solve([['a','b'],[['a','controls','b'],['a','controls','b']]],), [['a',[['controls','b']]],['b',[['controlled_by','a']]]])
check('contract fixture 4', solve([['a'],[['a','controls','a'],['a','unknown','a'],['a','controls','missing'],['missing','details','a']]],), [['a',[]]])
check('contract fixture 5', solve([['z','a'],[]],), [['z',[]],['a',[]]])
check('contract fixture 6', solve([[],[]],), [])
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)

prompt:
Nodes without relations disappear from snapshot results.

Input [node_ids,relations] relations [source,kind,target]. Kind label_for maps inverse labelled_by, description_for maps described_by, controls maps controlled_by, details maps details_for. Unknown types ignored. Resolve only existing distinct nodes. For each node output direct and inverse [kind,other_id] pairs, deduping while preserving relation encounter order. Direct is appended before inverse. Nodes with no links are retained in input order; input node IDs are unique. Forward and reverse kinds remain distinct even for reciprocal declarations.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    before,after = data
    result = []
    for ident in sorted(set()): result.append(['remove',ident,before[ident]['role']])
    for ident in sorted(set(after)-set(before),key=lambda x:(after[x]['order'],x)): result.append(['add',ident,after[ident]])
    for ident in sorted(set(before)&set(after)):
        old,new = before[ident],after[ident]
        if old['role'] != new['role']: result.append(['replace-role',ident,new['role']])
        elif old['name'] != new['name']: result.append(['set-name',ident,new['name']])
        if old['parent'] != new['parent'] or old['order'] != new['order']: result.append(['move',ident,new['parent'],new['order']])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'x':{'role':'image','name':'old','parent':'a','order':N}},{'x':{'role':'button','name':'new','parent':'b','order':N+1}}],), [['replace-role','x','button'],['move','x','b',N+1]])
check('contract fixture 2', solve([{'x':{'role':'image','name':'old','parent':None,'order':0}},{'x':{'role':'image','name':'','parent':None,'order':0}}],), [['set-name','x','']])
check('contract fixture 3', solve([{'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}},{}],), [['remove','a','group'],['remove','z','image']])
check('contract fixture 4', solve([{}, {'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}}],), [['add','z',{'role':'image','name':'Z','parent':None,'order':0}],['add','a',{'role':'group','name':'A','parent':None,'order':1}]])
check('contract fixture 5', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'a','order':N}}],), [['move','x','a',N]])
check('contract fixture 6', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'b','order':0}}],), [['move','x','b',0]])
check('contract fixture 7', solve([{},{}],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    before,after = data
    result = []
    for ident in sorted(set(before)&set(after)): result.append(['remove',ident,before[ident]['role']])
    for ident in sorted(set(after)-set(before),key=lambda x:(after[x]['order'],x)): result.append(['add',ident,after[ident]])
    for ident in sorted(set(before)&set(after)):
        old,new = before[ident],after[ident]
        if old['role'] != new['role']: result.append(['replace-role',ident,new['role']])
        elif old['name'] != new['name']: result.append(['set-name',ident,new['name']])
        if old['parent'] != new['parent'] or old['order'] != new['order']: result.append(['move',ident,new['parent'],new['order']])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'x':{'role':'image','name':'old','parent':'a','order':N}},{'x':{'role':'button','name':'new','parent':'b','order':N+1}}],), [['replace-role','x','button'],['move','x','b',N+1]])
check('contract fixture 2', solve([{'x':{'role':'image','name':'old','parent':None,'order':0}},{'x':{'role':'image','name':'','parent':None,'order':0}}],), [['set-name','x','']])
check('contract fixture 3', solve([{'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}},{}],), [['remove','a','group'],['remove','z','image']])
check('contract fixture 4', solve([{}, {'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}}],), [['add','z',{'role':'image','name':'Z','parent':None,'order':0}],['add','a',{'role':'group','name':'A','parent':None,'order':1}]])
check('contract fixture 5', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'a','order':N}}],), [['move','x','a',N]])
check('contract fixture 6', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'b','order':0}}],), [['move','x','b',0]])
check('contract fixture 7', solve([{},{}],), [])
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)

prompt:
Removed objects are mistaken for newly added objects.

Input [before,after] maps stable object ID to {role,name,parent,order}. Return delta operations in phases: removed IDs sorted lexical; added IDs sorted by after order then ID; common IDs sorted lexical get role-replace if role differs, otherwise name-set if name differs; parent/order changes append move even after role-replace. Removed values use old role, added records preserve complete new record, name-set preserves empty names. Same ID is never remove+add just for role changes. Return operations lists.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    before,after = data
    result = []
    for ident in [x for x in before if x not in after]: result.append(['remove',ident,before[ident]['role']])
    for ident in sorted(set(after)-set(before),key=lambda x:(after[x]['order'],x)): result.append(['add',ident,after[ident]])
    for ident in sorted(set(before)&set(after)):
        old,new = before[ident],after[ident]
        if old['role'] != new['role']: result.append(['replace-role',ident,new['role']])
        elif old['name'] != new['name']: result.append(['set-name',ident,new['name']])
        if old['parent'] != new['parent'] or old['order'] != new['order']: result.append(['move',ident,new['parent'],new['order']])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'x':{'role':'image','name':'old','parent':'a','order':N}},{'x':{'role':'button','name':'new','parent':'b','order':N+1}}],), [['replace-role','x','button'],['move','x','b',N+1]])
check('contract fixture 2', solve([{'x':{'role':'image','name':'old','parent':None,'order':0}},{'x':{'role':'image','name':'','parent':None,'order':0}}],), [['set-name','x','']])
check('contract fixture 3', solve([{'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}},{}],), [['remove','a','group'],['remove','z','image']])
check('contract fixture 4', solve([{}, {'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}}],), [['add','z',{'role':'image','name':'Z','parent':None,'order':0}],['add','a',{'role':'group','name':'A','parent':None,'order':1}]])
check('contract fixture 5', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'a','order':N}}],), [['move','x','a',N]])
check('contract fixture 6', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'b','order':0}}],), [['move','x','b',0]])
check('contract fixture 7', solve([{},{}],), [])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(data):
    before,after = data
    result = []
    for ident in sorted(set(before)-set(after),reverse=True): result.append(['remove',ident,before[ident]['role']])
    for ident in sorted(set(after)-set(before),key=lambda x:(after[x]['order'],x)): result.append(['add',ident,after[ident]])
    for ident in sorted(set(before)&set(after)):
        old,new = before[ident],after[ident]
        if old['role'] != new['role']: result.append(['replace-role',ident,new['role']])
        elif old['name'] != new['name']: result.append(['set-name',ident,new['name']])
        if old['parent'] != new['parent'] or old['order'] != new['order']: result.append(['move',ident,new['parent'],new['order']])
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'x':{'role':'image','name':'old','parent':'a','order':N}},{'x':{'role':'button','name':'new','parent':'b','order':N+1}}],), [['replace-role','x','button'],['move','x','b',N+1]])
check('contract fixture 2', solve([{'x':{'role':'image','name':'old','parent':None,'order':0}},{'x':{'role':'image','name':'','parent':None,'order':0}}],), [['set-name','x','']])
check('contract fixture 3', solve([{'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}},{}],), [['remove','a','group'],['remove','z','image']])
check('contract fixture 4', solve([{}, {'z':{'role':'image','name':'Z','parent':None,'order':0},'a':{'role':'group','name':'A','parent':None,'order':1}}],), [['add','z',{'role':'image','name':'Z','parent':None,'order':0}],['add','a',{'role':'group','name':'A','parent':None,'order':1}]])
check('contract fixture 5', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'a','order':N}}],), [['move','x','a',N]])
check('contract fixture 6', solve([{'x':{'role':'image','name':'X','parent':'a','order':0}},{'x':{'role':'image','name':'X','parent':'b','order':0}}],), [['move','x','b',0]])
check('contract fixture 7', solve([{},{}],), [])
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)

prompt:
Removal deltas retain arbitrary transport insertion order.

Input [before,after] maps stable object ID to {role,name,parent,order}. Return delta operations in phases: removed IDs sorted lexical; added IDs sorted by after order then ID; common IDs sorted lexical get role-replace if role differs, otherwise name-set if name differs; parent/order changes append move even after role-replace. Removed values use old role, added records preserve complete new record, name-set preserves empty names. Same ID is never remove+add just for role changes. Return operations lists.

split: open-access