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

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'explicit'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
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):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native' if interactive else 'explicit'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
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:
Native roles are incorrectly marked as author overrides.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


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

N = 1
observations = []
def solve(data):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'explicit'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
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):
    tokens,native,interactive,required,supported = data
    known = {'group','link','image','button','article','generic','presentation'}
    chosen = None
    source = 'native'
    for token in tokens.split():
        if token not in known: continue
        if token == 'presentation' and interactive: continue
        if required and token != native: continue
        chosen = token
        source = 'explicit'
        break
    if chosen is None: chosen = native
    if chosen not in supported:
        chosen = native if native in supported else 'generic'
        source = 'fallback' if not supported else 'native'
    interface = {'link':'action','button':'action','image':'image','article':'container','group':'container'}.get(chosen)
    return [chosen,interface,source]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ordered fallback', solve(['unknown command group link','image',False,False,['group','link','image']],), ['group','container','explicit'])
check('interactive presentation', solve(['presentation link','button',True,False,['presentation','link','button']],), ['link','action','explicit'])
check('required role', solve(['link image','image',False,True,['image','link']],), ['image','image','explicit'])
check('native fallback', solve(['article','image',False,False,['image']],), ['image','image','fallback'])
check('no supported native', solve(['group','image',False,False,[]],), ['generic',None,'fallback'])
check('empty uses native', solve([' '*N,'button',True,False,['button']],), ['button','action','native'])
check('unknown only', solve(['unknown'+str(N),['article','image','button','group','link'][N-1],False,False,['article','image','button','group','link']],), [['article','image','button','group','link'][N-1],['container','image','action','container','action'][N-1],'native'])
check('presentation retained', solve(['presentation','image',False,False,['presentation']],), ['presentation',None,'explicit'])
check('tab separated', solve(['unknown\timage','group',False,False,['image','group']],), ['image','image','explicit'])
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:
Role fallback retains the explicit-source marker.

Resolve an adapter role from ordered author tokens, native role, interactivity, required-role constraint and platform support. Supported abstract roles are group, link, image, button, article, generic and presentation. Skip unknown and abstract tokens (command, structure). Only first usable explicit token wins. Presentation is ignored on interactive objects; required native role (when required true) rejects incompatible overrides except native itself. Unsupported platform roles fall back to native if supported, otherwise generic. Generic yields no interface; link and button yield action, image yields image, article/group yield container. Return [role,interface,source] where source is explicit, native, or fallback.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if False: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind == 'unknown': continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unknown relationship types enter the platform bridge.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if False: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td and si == ti: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Relations cross embedded document boundaries.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if target is None: continue
        source = source or (True,False)
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if target is None: continue
        source = source or (si != '',False)
        if not source[0] or source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unresolved source identifiers produce dangling relations.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if source[1]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if source[1] or (not source[0] and si == ti): continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Relations survive an unexposed source.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0]: continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or (source[1] and not source[0]): continue
        if not target[0] or target[1]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Defunct sources retain outgoing semantic links.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0]: continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    nodes,requests = data
    index = {(doc,ident):(visible,dead) for doc,ident,visible,dead in nodes}
    result = []
    seen = set()
    for sd,si,td,ti,kind in requests:
        if kind not in {'details','controls','describedby'}: continue
        if sd != td: continue
        source = index.get((sd,si))
        target = index.get((td,ti))
        if source is None or target is None: continue
        if not source[0] or source[1]: continue
        if not target[0] or (target[1] and si == ti): continue
        if si == ti: continue
        edge = (si,kind,ti)
        if edge in seen: continue
        seen.add(edge)
        result.append(list(edge))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('valid ordered and repeated', solve([[['d','s',True,False],['d','t',True,False],['d',str(N),True,False]],[['d','s','d','t','details'],['d','s','d',str(N),'controls'],['d','s','d','t','details']]],), [['s','details','t'],['s','controls',str(N)]])
check('different kinds same endpoints', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','details'],['d','s','d','t','controls']]],), [['s','details','t'],['s','controls','t']])
check('cross document collision', solve([[['d','s',True,False],['d','t',False,False],['e','t',True,False]],[['d','s','e','t','details'],['d','s','d','t','details']]],), [])
check('unsupported and self', solve([[['d','s',True,False],['d','t',True,False]],[['d','s','d','t','label'],['d','s','d','s','controls']]],), [])
check('missing endpoints', solve([[['d','s',True,False]],[['d','s','d','missing','details'],['d','gone','d','s','details']]],), [])
check('hidden source', solve([[['d','s',False,False],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct source', solve([[['d','s',True,True],['d','t',True,False]],[['d','s','d','t','details']]],), [])
check('defunct target', solve([[['d','s',True,False],['d','t',True,True]],[['d','s','d','t','details']]],), [])
check('empty snapshot', solve([[],[]],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Defunct targets remain resolvable.

Input [nodes,requests] with nodes [document,id,exposed,defunct] and requests [source_doc,source_id,target_doc,target_id,kind]. Allowed kinds details, controls, describedby. Resolve in document-scoped ID space, reject missing/hidden/defunct sources or targets, self edges, cross-document edges and unsupported kinds. Dedupe identical edges preserving request order. Return [source_id,kind,target_id]. IDs may repeat in different documents. Source and target visibility are direct snapshot flags, not ancestry.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
UTF16 range adapter counts astral text as one unit.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start = 0
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < -size: start = 0
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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 range starts are measured from zero.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end = 0
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < -size: end = 0
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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 range ends are measured from zero.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,start)
    if start < 0: return ['invalid',start,end,size]
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(-1,start))
    if start < 0: return ['invalid',start,end,size]
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Out-of-range negative starts escape normalization.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = max(0,end)
    if end > size: return ['invalid',start,end,size]
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size+1,max(0,end))
    if end > size: return ['invalid',start,end,size]
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Oversized range ends are rejected instead of clamped.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: end = start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start = end
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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 accessible ranges are collapsed.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = min(i for i,x in enumerate(edges) if x >= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start) if start == 0 else min(i for i,x in enumerate(edges) if x >= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Range start rounds into the next text character.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = max(i for i,x in enumerate(edges) if x <= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end) if end == size else max(i for i,x in enumerate(edges) if x <= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Range end drops a partially addressed astral character.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\r').replace('\x00','\ufffd')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Platform text ranges expose carriage-return duplicates.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    text,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').split('\x00')[0]
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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,start,end,unit = data
    widths = [2 if unit == 'utf16' and ord(c) > 65535 else 1 for c in text]
    edges = [0]
    for width in widths: edges.append(edges[-1]+width)
    size = edges[-1]
    if start < 0: start += size
    if end < 0: end += size
    start = min(size,max(0,start))
    end = min(size,max(0,end))
    if start > end: start,end = end,start
    left = max(i for i,x in enumerate(edges) if x <= start)
    right = min(i for i,x in enumerate(edges) if x >= end)
    snippet = text[left:right].replace('\r\n','\n').replace('\x00','')
    return [snippet,edges[left],edges[right],size]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('surrogate interior expands', solve(['A'*N+'😀Z',N+1,N+2,'utf16'],), ['😀',N,N+2,N+3])
check('negative start', solve(['A'*N+'BC',-2,N+2,'codepoint'],), ['BC',N,N+2,N+2])
check('negative end', solve(['A'*N+'BC',N,-1,'codepoint'],), ['B',N,N+1,N+2])
check('clamp both', solve(['AB',-20,40,'utf16'],), ['AB',0,2,2])
check('reverse', solve(['ABCDE',4,1,'codepoint'],), ['BCD',1,4,5])
check('CRLF normalization', solve(['A\r\nB',0,4,'utf16'],), ['A\nB',0,4,4])
check('NUL replacement', solve(['A\x00B',0,3,'utf16'],), ['A�B',0,3,3])
check('codepoint emoji', solve(['😀B',1,2,'codepoint'],), ['B',1,2,2])
check('empty', solve(['',0,0,'utf16'],), ['',0,0,0])
check('surrogate end expands', solve(['A😀Z',0,2,'utf16'],), ['A😀',0,3,4])
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:
Embedded NUL terminates accessible text content.

Input [text,start,end,unit] where indices are measured in utf16 or codepoint units. Negative indices count backward from end, clamp to valid extent, and sort reversed endpoints. A boundary inside a surrogate pair expands outward (start down, end up). CRLF is exposed as one LF after slicing. NUL becomes replacement character. Return [exposed_text,normalized_start,normalized_end,source_units]. UTF16 offsets refer to original source, not normalized text.

split: open-access


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

N = 1
observations = []
def solve(data):
    raw,protected,reveal,permission,readonly,multiline,cap,placeholder = data
    value = raw
    if not multiline: value = value.replace('\n',' ')
    if cap is not None: value = value[:cap]
    length = len(value)
    if protected and not (reveal and permission):
        value = ''.join('\n' if c == '\n' else '•' for c in value)
    return {'text':value,'placeholder':placeholder if length == 0 else '', 'length':length,'editable':not readonly,'protected':protected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('redacted multiline', solve(['A'*N+'\r\nB',True,False,True,False,True,None,'hint'],), {'text':'•'*N+'\n•','placeholder':'','length':N+2,'editable':True,'protected':True})
check('reveal lacks permission', solve(['A'*N,True,True,False,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('permission lacks reveal', solve(['A'*N,True,False,True,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('authorized reveal readonly', solve(['secret',True,True,True,True,False,None,'hint'],), {'text':'secret','placeholder':'','length':6,'editable':False,'protected':True})
check('single line cap', solve(['A\r\nBC',False,False,False,False,False,3,'hint'],), {'text':'A B','placeholder':'','length':3,'editable':True,'protected':False})
check('zero cap placeholder', solve(['secret',True,False,False,False,False,0,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':True,'protected':True})
check('empty value', solve(['',False,False,False,True,False,None,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':False,'protected':False})
check('unicode codepoints', solve(['😀é',True,False,False,False,True,None,''],), {'text':'••','placeholder':'','length':2,'editable':True,'protected':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):
    raw,protected,reveal,permission,readonly,multiline,cap,placeholder = data
    value = raw.replace('\r','') if cap is None else raw
    if not multiline: value = value.replace('\n',' ')
    if cap is not None: value = value[:cap]
    length = len(value)
    if protected and not (reveal and permission):
        value = ''.join('\n' if c == '\n' else '•' for c in value)
    return {'text':value,'placeholder':placeholder if length == 0 else '', 'length':length,'editable':not readonly,'protected':protected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('redacted multiline', solve(['A'*N+'\r\nB',True,False,True,False,True,None,'hint'],), {'text':'•'*N+'\n•','placeholder':'','length':N+2,'editable':True,'protected':True})
check('reveal lacks permission', solve(['A'*N,True,True,False,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('permission lacks reveal', solve(['A'*N,True,False,True,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('authorized reveal readonly', solve(['secret',True,True,True,True,False,None,'hint'],), {'text':'secret','placeholder':'','length':6,'editable':False,'protected':True})
check('single line cap', solve(['A\r\nBC',False,False,False,False,False,3,'hint'],), {'text':'A B','placeholder':'','length':3,'editable':True,'protected':False})
check('zero cap placeholder', solve(['secret',True,False,False,False,False,0,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':True,'protected':True})
check('empty value', solve(['',False,False,False,True,False,None,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':False,'protected':False})
check('unicode codepoints', solve(['😀é',True,False,False,False,True,None,''],), {'text':'••','placeholder':'','length':2,'editable':True,'protected':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:
CRLF consumes two places in a protected value cap.

Input [raw,protected,reveal,permission,readonly,multiline,max_length,placeholder]. Raw is a string; max_length is None or nonnegative. Normalize CRLF before applying codepoint cap. In single line replace LF with space. Protected text reveals only when reveal and permission; otherwise one bullet per capped codepoint excluding LF, which is retained. Empty values retain empty text and expose placeholder separately. Return {text,placeholder,length,editable,protected}; length is the length after cap, editable is not readonly, protected reports input flag even when revealed.

split: open-access


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

N = 1
observations = []
def solve(data):
    raw,protected,reveal,permission,readonly,multiline,cap,placeholder = data
    value = raw.replace('\r\n','\n')
    if False: value = value.replace('\n',' ')
    if cap is not None: value = value[:cap]
    length = len(value)
    if protected and not (reveal and permission):
        value = ''.join('\n' if c == '\n' else '•' for c in value)
    return {'text':value,'placeholder':placeholder if length == 0 else '', 'length':length,'editable':not readonly,'protected':protected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('redacted multiline', solve(['A'*N+'\r\nB',True,False,True,False,True,None,'hint'],), {'text':'•'*N+'\n•','placeholder':'','length':N+2,'editable':True,'protected':True})
check('reveal lacks permission', solve(['A'*N,True,True,False,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('permission lacks reveal', solve(['A'*N,True,False,True,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('authorized reveal readonly', solve(['secret',True,True,True,True,False,None,'hint'],), {'text':'secret','placeholder':'','length':6,'editable':False,'protected':True})
check('single line cap', solve(['A\r\nBC',False,False,False,False,False,3,'hint'],), {'text':'A B','placeholder':'','length':3,'editable':True,'protected':False})
check('zero cap placeholder', solve(['secret',True,False,False,False,False,0,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':True,'protected':True})
check('empty value', solve(['',False,False,False,True,False,None,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':False,'protected':False})
check('unicode codepoints', solve(['😀é',True,False,False,False,True,None,''],), {'text':'••','placeholder':'','length':2,'editable':True,'protected':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):
    raw,protected,reveal,permission,readonly,multiline,cap,placeholder = data
    value = raw.replace('\r\n','\n')
    if not multiline: value = value.replace('\n','')
    if cap is not None: value = value[:cap]
    length = len(value)
    if protected and not (reveal and permission):
        value = ''.join('\n' if c == '\n' else '•' for c in value)
    return {'text':value,'placeholder':placeholder if length == 0 else '', 'length':length,'editable':not readonly,'protected':protected}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('redacted multiline', solve(['A'*N+'\r\nB',True,False,True,False,True,None,'hint'],), {'text':'•'*N+'\n•','placeholder':'','length':N+2,'editable':True,'protected':True})
check('reveal lacks permission', solve(['A'*N,True,True,False,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('permission lacks reveal', solve(['A'*N,True,False,True,False,False,None,'hint'],), {'text':'•'*N,'placeholder':'','length':N,'editable':True,'protected':True})
check('authorized reveal readonly', solve(['secret',True,True,True,True,False,None,'hint'],), {'text':'secret','placeholder':'','length':6,'editable':False,'protected':True})
check('single line cap', solve(['A\r\nBC',False,False,False,False,False,3,'hint'],), {'text':'A B','placeholder':'','length':3,'editable':True,'protected':False})
check('zero cap placeholder', solve(['secret',True,False,False,False,False,0,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':True,'protected':True})
check('empty value', solve(['',False,False,False,True,False,None,'hint'],), {'text':'','placeholder':'hint','length':0,'editable':False,'protected':False})
check('unicode codepoints', solve(['😀é',True,False,False,False,True,None,''],), {'text':'••','placeholder':'','length':2,'editable':True,'protected':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:
Single-line accessible value retains line breaks.

Input [raw,protected,reveal,permission,readonly,multiline,max_length,placeholder]. Raw is a string; max_length is None or nonnegative. Normalize CRLF before applying codepoint cap. In single line replace LF with space. Protected text reveals only when reveal and permission; otherwise one bullet per capped codepoint excluding LF, which is retained. Empty values retain empty text and expose placeholder separately. Return {text,placeholder,length,editable,protected}; length is the length after cap, editable is not readonly, protected reports input flag even when revealed.

split: open-access