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

N = 1
observations = []
def solve(data):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and True
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,(str,int)) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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:
Nontext semantic values enter the string property bridge.

Input [initial,revision,updates]. Updates [base_revision,next_revision,changes] apply atomically only if base matches current and next is greater; updates cannot change immutable id or role. Allowed dynamic keys name,description,value,help,language; unknown keys reject whole update. None deletes a property, empty string is retained; values must be strings or None. Return [state,revision,accepted_flags]. Copy initial. Revision advances even for no-op changes.

split: open-access


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

N = 1
observations = []
def solve(data):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state[key] = None
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state[key] = ''
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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 semantic properties remain as explicit nulls.

Input [initial,revision,updates]. Updates [base_revision,next_revision,changes] apply atomically only if base matches current and next is greater; updates cannot change immutable id or role. Allowed dynamic keys name,description,value,help,language; unknown keys reject whole update. None deletes a property, empty string is retained; values must be strings or None. Return [state,revision,accepted_flags]. Copy initial. Revision advances even for no-op changes.

split: open-access


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

N = 1
observations = []
def solve(data):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if not value: state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value in (None,''): state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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:
Intentional empty semantic properties are discarded.

Input [initial,revision,updates]. Updates [base_revision,next_revision,changes] apply atomically only if base matches current and next is greater; updates cannot change immutable id or role. Allowed dynamic keys name,description,value,help,language; unknown keys reject whole update. None deletes a property, empty string is retained; values must be strings or None. Return [state,revision,accepted_flags]. Copy initial. Revision advances even for no-op changes.

split: open-access


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

N = 1
observations = []
def solve(data):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt if changes else revision
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid: continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt if any(v is not None for v in changes.values()) else revision
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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:
An empty semantic patch fails to advance revision.

Input [initial,revision,updates]. Updates [base_revision,next_revision,changes] apply atomically only if base matches current and next is greater; updates cannot change immutable id or role. Allowed dynamic keys name,description,value,help,language; unknown keys reject whole update. None deletes a property, empty string is retained; values must be strings or None. Return [state,revision,accepted_flags]. Copy initial. Revision advances even for no-op changes.

split: open-access


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

N = 1
observations = []
def solve(data):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid:
            revision = nxt
            continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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):
    initial,revision,updates = data
    state = dict(initial)
    accepted = []
    for base,nxt,changes in updates:
        valid = base == revision and nxt > base
        valid = valid and all(k in {'name','description','value','help','language'} for k in changes)
        valid = valid and all(v is None or isinstance(v,str) for v in changes.values())
        accepted.append(valid)
        if not valid:
            revision = max(revision,nxt)
            continue
        for key,value in changes.items():
            if value is None: state.pop(key,None)
            else: state[key] = value
        revision = nxt
    return [state,revision,accepted]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'id':'x','role':'image','name':'old'},N,[[N,N+1,{'name':'new','help':''}],[N,N+2,{'name':'stale'}]]],), [{'id':'x','role':'image','name':'new','help':''},N+1,[True,False]])
check('contract fixture 2', solve([{'name':'x','help':'h'},N,[[N,N+1,{'name':None}],[N+1,N+2,{'absent':'bad','help':'bad'}]]],), [{'help':'h'},N+1,[True,False]])
check('contract fixture 3', solve([{'id':'x','role':'image'},N,[[N,N+1,{'id':'y'}],[N,N+1,{'role':'button'}]]],), [{'id':'x','role':'image'},N,[False,False]])
check('contract fixture 4', solve([{},N,[[N,N,{'name':'bad'}],[N,N-1,{}],[N,N+1,{}]]],), [{},N+1,[False,False,True]])
check('contract fixture 5', solve([{'name':'x'},N,[[N,N+1,{'name':42,'help':'partial'}]]],), [{'name':'x'},N,[False]])
check('contract fixture 6', solve([{},N,[[N,N+1,{'name':None,'description':'D','value':'0','language':'en'}]]],), [{'description':'D','value':'0','language':'en'},N+1,[True]])
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:
Rejected semantic patches consume revision numbers.

Input [initial,revision,updates]. Updates [base_revision,next_revision,changes] apply atomically only if base matches current and next is greater; updates cannot change immutable id or role. Allowed dynamic keys name,description,value,help,language; unknown keys reject whole update. None deletes a property, empty string is retained; values must be strings or None. Return [state,revision,accepted_flags]. Copy initial. Revision advances even for no-op changes.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if False: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested > revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
Child pages mix snapshots after a document revision.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if not isinstance(start,int) or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if not isinstance(start,(int,bool)) or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
Boolean child offsets become integer indices.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or not isinstance(count,int) or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or not isinstance(count,(int,bool)) or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
Boolean page capacities are treated as a one-child request.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int  or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < -1 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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 child offsets address the final page.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 : return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < -1: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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 child capacities silently truncate results.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if True]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed or x == 'hidden']
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
Unexposed child placeholders consume page capacity.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in children if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in (children if start == 0 else dict.fromkeys(children)) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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 semantic children occupy multiple page slots.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:count]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count-1]
    nxt = start+len(page) if page and start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
Child pagination treats capacity as an absolute end offset.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if count == 0 or start+len(page) < len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
An empty child page advertises a continuation to itself.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) <= len(items) else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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):
    children,start,count,revision,requested,exposed = data
    if requested != revision: return {'error':'stale'}
    if type(start) is not int or type(count) is not int or start < 0 or count < 0: return {'error':'range'}
    items = [x for x in dict.fromkeys(children) if x in exposed]
    page = items[start:start+count]
    nxt = start+len(page) if page and start+len(page) != len(items)-1 else None
    return {'children':page,'total':len(items),'next':nxt,'revision':revision}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([['a','hidden','b','a','c'],0,2,N,N,['a','b','c']],), {'children':['a','b'],'total':3,'next':2,'revision':N})
check('contract fixture 2', solve([['a','b','c'],2,4,N,N,['a','b','c']],), {'children':['c'],'total':3,'next':None,'revision':N})
check('contract fixture 3', solve([['a','b'],0,0,N,N,['a','b']],), {'children':[],'total':2,'next':None,'revision':N})
check('contract fixture 4', solve([['a'],-1,2,N,N-1,['a']],), {'error':'stale'})
check('contract fixture 5', solve([['a'],True,1,N,N,['a']],), {'error':'range'})
check('contract fixture 6', solve([['a'],0,False,N,N,['a']],), {'error':'range'})
check('contract fixture 7', solve([['a'],0,-1,N,N,['a']],), {'error':'range'})
check('contract fixture 8', solve([['a'],-1,1,N,N,['a']],), {'error':'range'})
check('contract fixture 9', solve([['a','b','c'],1,1,N,N,['a','b','c']],), {'children':['b'],'total':3,'next':2,'revision':N})
check('contract fixture 10', solve([['a'],N+2,1,N,N,['a']],), {'children':[],'total':1,'next':None,'revision':N})
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:
A terminal child page advertises an extra empty page.

Input [children,start,count,revision,requested_revision,exposed_ids]. Page accessibility child descriptors in source order, first dedupe IDs then filter exposed IDs. start/count must be nonnegative integers excluding booleans; invalid returns {error:range}. Stale requested revision returns {error:stale} before range checks. Return children slice, total exposed unique count, next offset or None, revision. Zero count yields empty page with next None to avoid nonprogress. Start beyond total gives empty and next None.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if False or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if (readonly and maximum is not None) or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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 text exposes a mutating accessibility edit path.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (-1 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Accessible edits accept negative source offsets.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= len(text) and 0 <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= len(text) and end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Reversed edit ranges duplicate accessible text.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= True):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)+1):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Edit end beyond current text is silently accepted.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end+1:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[max(start,end-1):]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Text replacement deletes one extra codepoint.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+text[end:]+replacement
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = replacement+text[:start]+text[end:]
        if maximum is not None and len(proposed) > maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Replacement text is appended at the end of the control.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) >= maximum:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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):
    text,readonly,maximum,operations = data
    results = []
    for start,end,replacement in operations:
        if readonly or not (0 <= start <= end <= len(text)):
            results.append([False,None,0]); continue
        proposed = text[:start]+replacement+text[end:]
        if maximum is not None and len(proposed) > maximum-1:
            results.append([False,None,0]); continue
        delta = len(replacement)-(end-start)
        text = proposed
        results.append([True,start+len(replacement),delta])
    return [text,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',False,None,[[N,N+1,'xy'],[N+2,N+3,'']]],), ['A'*N+'xy',[[True,N+2,1],[True,N+2,-1]]])
check('contract fixture 2', solve(['ab',False,3,[[1,1,'X'],[0,0,'Y']]],), ['aXb',[[True,2,1],[False,None,0]]])
check('contract fixture 3', solve(['ab',True,None,[[0,2,'x']]],), ['ab',[[False,None,0]]])
check('contract fixture 4', solve(['ab',False,None,[[-1,1,'x'],[2,1,'x'],[0,3,'x']]],), ['ab',[[False,None,0],[False,None,0],[False,None,0]]])
check('contract fixture 5', solve(['',False,0,[[0,0,''],[0,0,'x']]],), ['',[[True,0,0],[False,None,0]]])
check('contract fixture 6', solve(['😀x',False,None,[[0,1,'é']]],), ['éx',[[True,1,0]]])
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:
Text exactly at the declared maximum is rejected.

Input [text,readonly,maximum,operations] operations [start,end,replacement]. Validate integer codepoint bounds 0<=start<=end<=len(current_text); readonly rejects each edit. Replace half-open range; reject proposed length beyond maximum (None unlimited) atomically. Return [final_text,edit_results] where successful result [True,caret,delta] caret is start+replacement length and delta replacement length minus removed length; rejected [False,None,0]. Empty replacement deletes, empty interval inserts. Subsequent offsets address current text.

split: open-access