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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation : parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and len(annotation)>0: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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:
Identical base and pronunciation are exposed twice.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append((annotation,'annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append((' '+annotation,'annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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:
Combined ruby output omits pronunciation delimiters.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base+fallback,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(fallback+base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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:
Ruby fallback markup enters semantic text.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if False: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if value is None: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Empty ruby segments create phantom text attribute runs.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),'en',source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language or 'en',source])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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:
Pronunciation language is silently replaced with a default.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,'base'])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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):
    segments,mode = data
    text = ''
    runs = []
    for base,annotation,fallback,language,hidden in segments:
        annotation = '' if hidden else annotation
        parts = []
        if mode == 'annotation' and annotation: parts = [(annotation,'annotation')]
        else:
            parts = [(base,'base')]
            if mode == 'combined' and annotation and annotation != base: parts.append(('('+annotation+')','annotation'))
        for value,source in parts:
            if not value: continue
            start = len(text)
            text += value
            runs.append([start,len(text),language,'annotation'])
    return [text,runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([[['字'*N,'ji','fallback','ja',False]],'combined'],), ['字'*N+'(ji)',[[0,N,'ja','base'],[N,N+4,'ja','annotation']]])
check('contract fixture 2', solve([[['字','ji','fallback','ja',False]],'annotation'],), ['ji',[[0,2,'ja','annotation']]])
check('contract fixture 3', solve([[['字','ji','fallback','ja',True]],'annotation'],), ['字',[[0,1,'ja','base']]])
check('contract fixture 4', solve([[['same','same','fallback','',False]],'combined'],), ['same',[[0,4,'','base']]])
check('contract fixture 5', solve([[['A','','fallback','en',False],['B','bee','fallback','en',False]],'base'],), ['AB',[[0,1,'en','base'],[1,2,'en','base']]])
check('contract fixture 6', solve([[['','','fallback','en',False]],'combined'],), ['',[]])
check('contract fixture 7', solve([[['A','','fallback','en',False]],'annotation'],), ['A',[[0,1,'en','base']]])
check('contract fixture 8', solve([[],'annotation'],), ['',[]])
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:
Pronunciation ranges are mislabeled as base text.

Input [segments,mode] where segments [base,annotation,fallback,language,hidden_annotation]. mode is base,annotation,combined. In annotation mode use nonempty visible annotation, otherwise base. Combined adds parenthesized visible annotation only when nonempty and different from base; fallback is markup-only content and never exposed. Return [text,runs] with runs [start,end,language,source], omitting zero-length contributions. Each segment is concatenated without implicit spaces. Combined annotation run includes parentheses. Source is base or annotation. Preserve original strings and language, including empty language.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return kind
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','').upper()
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Math tokens expose their node kind instead of content.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return render(children[0]) if len(children)==1 else 'malformed'
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('value') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Authored math alternatives lose priority over structure.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative','')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') if 'alternative' in node else (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An explicitly empty math alternative erases structure.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[1],'over',parts[0],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[0],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Math fraction operands are spoken in denominator-first order.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Nested math fractions lose their closing boundary.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[1],'to power',parts[0]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[0]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Math exponent and base are swapped in semantic output.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0]]
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Root expressions omit their semantic scope boundary.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['open']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = parts
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Fenced math expressions use an opening marker at both ends.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(out)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'unsupported'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part if part else ' ' for part in out)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Empty math nodes introduce extra semantic separators.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return ''
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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):
    def render(node):
        kind = node['kind']
        children = node.get('children',[])
        if kind == 'token': return node.get('value','')
        if kind == 'annotation': return node.get('alternative') or (render(children[0]) if len(children)==1 else 'malformed')
        if kind in ('fraction','power') and len(children)!=2: return 'malformed'
        if kind == 'root' and len(children)!=1: return 'malformed'
        if kind not in ('row','fraction','power','root','fenced'): return 'malformed'
        parts = [render(child) for child in children]
        if kind == 'row': out = parts
        elif kind == 'fraction': out = ['fraction',parts[0],'over',parts[1],'end fraction']
        elif kind == 'power': out = [parts[0],'to power',parts[1]]
        elif kind == 'root': out = ['square root',parts[0],'end root']
        else: out = ['open']+parts+['close']
        return ' '.join(part for part in out if part)
    return render(data)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve({'kind':'fraction','children':[{'kind':'token','value':str(N)},{'kind':'token','value':'x'}]},), 'fraction '+str(N)+' over x end fraction')
check('contract fixture 2', solve({'kind':'power','children':[{'kind':'token','value':'x'},{'kind':'token','value':str(N)}]},), 'x to power '+str(N))
check('contract fixture 3', solve({'kind':'root','children':[{'kind':'token','value':'x'}]},), 'square root x end root')
check('contract fixture 4', solve({'kind':'fenced','children':[{'kind':'row','children':[{'kind':'token','value':''},{'kind':'token','value':'x'}]}]},), 'open x close')
check('contract fixture 5', solve({'kind':'annotation','alternative':'custom','children':[{'kind':'token','value':'x'}]},), 'custom')
check('contract fixture 6', solve({'kind':'annotation','alternative':'','children':[{'kind':'token','value':'x'}]},), 'x')
check('contract fixture 7', solve({'kind':'fraction','children':[]},), 'malformed')
check('contract fixture 8', solve({'kind':'root','children':[]},), 'malformed')
check('contract fixture 9', solve({'kind':'unknown','children':[]},), 'unsupported')
check('contract fixture 10', solve({'kind':'row','children':[]},), '')
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:
Unsupported math nodes are silently exposed as empty rows.

Input AST limited to token(value), row(children), fraction(two children), power(two children), root(one child), fenced(children), annotation(primary,alternative) encoded dict kind, value, children, alternative. Empty rows expose empty string. Tokens preserve value. Fraction says fraction numerator over denominator end fraction; power says base to power exponent; root says square root child end root; fenced says open contents close. Empty child output omitted between single spaces. Annotation uses a nonempty alternative verbatim, otherwise its sole primary child. Unknown kinds return unsupported; wrong arity returns malformed without traversing children.

split: open-access


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

N = 1
observations = []
def solve(data):
    objects,queries,revision,expected = data
    results = []
    for ident,prop in queries:
        if expected > revision: results.append(['stale',None]); continue
        record = objects.get(ident)
        if record is None or not record[0]: results.append(['gone',None]); continue
        values = record[1]
        if prop not in {'name','value','description','role'} or prop not in values:
            results.append(['unsupported',None]); continue
        results.append(['ok',values.get(prop)])
    return [revision,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'a':[True,{'name':'A'+str(N),'value':None,'description':'','role':'image'}]},[['a','name'],['a','value'],['a','description'],['a','name']],N,N],), [N,[['ok','A'+str(N)],['ok',None],['ok',''],['ok','A'+str(N)]]])
check('contract fixture 2', solve([{'a':[True,{'secret':'s','name':'A'}]},[['a','secret'],['a','role']],N,N],), [N,[['unsupported',None],['unsupported',None]]])
check('contract fixture 3', solve([{'dead':[False,{'name':'secret'}]},[['missing','name'],['dead','name']],N,N],), [N,[['gone',None],['gone',None]]])
check('contract fixture 4', solve([{'a':[True,{'name':'A'}]},[['a','name'],['missing','role']],N,N-1],), [N,[['stale',None],['stale',None]]])
check('contract fixture 5', solve([{'a':[True,{'name':'A'}]},[['a','name']],N,N+1],), [N,[['stale',None]]])
check('contract fixture 6', solve([{},[],N,N],), [N,[]])
check('contract fixture 7', solve([{'z':[True,{'name':'Z'}],'a':[True,{'name':'A'}]},[['z','name'],['a','name']],N,N],), [N,[['ok','Z'],['ok','A']]])
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):
    objects,queries,revision,expected = data
    results = []
    for ident,prop in queries:
        if expected < revision: results.append(['stale',None]); continue
        record = objects.get(ident)
        if record is None or not record[0]: results.append(['gone',None]); continue
        values = record[1]
        if prop not in {'name','value','description','role'} or prop not in values:
            results.append(['unsupported',None]); continue
        results.append(['ok',values.get(prop)])
    return [revision,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'a':[True,{'name':'A'+str(N),'value':None,'description':'','role':'image'}]},[['a','name'],['a','value'],['a','description'],['a','name']],N,N],), [N,[['ok','A'+str(N)],['ok',None],['ok',''],['ok','A'+str(N)]]])
check('contract fixture 2', solve([{'a':[True,{'secret':'s','name':'A'}]},[['a','secret'],['a','role']],N,N],), [N,[['unsupported',None],['unsupported',None]]])
check('contract fixture 3', solve([{'dead':[False,{'name':'secret'}]},[['missing','name'],['dead','name']],N,N],), [N,[['gone',None],['gone',None]]])
check('contract fixture 4', solve([{'a':[True,{'name':'A'}]},[['a','name'],['missing','role']],N,N-1],), [N,[['stale',None],['stale',None]]])
check('contract fixture 5', solve([{'a':[True,{'name':'A'}]},[['a','name']],N,N+1],), [N,[['stale',None]]])
check('contract fixture 6', solve([{},[],N,N],), [N,[]])
check('contract fixture 7', solve([{'z':[True,{'name':'Z'}],'a':[True,{'name':'A'}]},[['z','name'],['a','name']],N,N],), [N,[['ok','Z'],['ok','A']]])
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:
Batch semantic reads use an outdated expected revision.

Input [objects,queries,revision,expected_revision]. objects map IDs to [alive,properties]; queries [id,property]. Allowed props name,value,description,role; a missing property is unsupported while an existing None is successful null. Results retain query order and duplicates, each [status,value]; status stale for every query when revisions differ, gone for missing/defunct object, unsupported for unknown/absent property, ok otherwise. Empty queries produce empty output. Return [revision,results], actual revision always. Values are returned as JSON-compatible content; object aliasing is outside this query-only model.

split: open-access


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

N = 1
observations = []
def solve(data):
    objects,queries,revision,expected = data
    results = []
    for ident,prop in sorted(queries):
        if expected != revision: results.append(['stale',None]); continue
        record = objects.get(ident)
        if record is None or not record[0]: results.append(['gone',None]); continue
        values = record[1]
        if prop not in {'name','value','description','role'} or prop not in values:
            results.append(['unsupported',None]); continue
        results.append(['ok',values.get(prop)])
    return [revision,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'a':[True,{'name':'A'+str(N),'value':None,'description':'','role':'image'}]},[['a','name'],['a','value'],['a','description'],['a','name']],N,N],), [N,[['ok','A'+str(N)],['ok',None],['ok',''],['ok','A'+str(N)]]])
check('contract fixture 2', solve([{'a':[True,{'secret':'s','name':'A'}]},[['a','secret'],['a','role']],N,N],), [N,[['unsupported',None],['unsupported',None]]])
check('contract fixture 3', solve([{'dead':[False,{'name':'secret'}]},[['missing','name'],['dead','name']],N,N],), [N,[['gone',None],['gone',None]]])
check('contract fixture 4', solve([{'a':[True,{'name':'A'}]},[['a','name'],['missing','role']],N,N-1],), [N,[['stale',None],['stale',None]]])
check('contract fixture 5', solve([{'a':[True,{'name':'A'}]},[['a','name']],N,N+1],), [N,[['stale',None]]])
check('contract fixture 6', solve([{},[],N,N],), [N,[]])
check('contract fixture 7', solve([{'z':[True,{'name':'Z'}],'a':[True,{'name':'A'}]},[['z','name'],['a','name']],N,N],), [N,[['ok','Z'],['ok','A']]])
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):
    objects,queries,revision,expected = data
    results = []
    for ident,prop in reversed(queries):
        if expected != revision: results.append(['stale',None]); continue
        record = objects.get(ident)
        if record is None or not record[0]: results.append(['gone',None]); continue
        values = record[1]
        if prop not in {'name','value','description','role'} or prop not in values:
            results.append(['unsupported',None]); continue
        results.append(['ok',values.get(prop)])
    return [revision,results]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve([{'a':[True,{'name':'A'+str(N),'value':None,'description':'','role':'image'}]},[['a','name'],['a','value'],['a','description'],['a','name']],N,N],), [N,[['ok','A'+str(N)],['ok',None],['ok',''],['ok','A'+str(N)]]])
check('contract fixture 2', solve([{'a':[True,{'secret':'s','name':'A'}]},[['a','secret'],['a','role']],N,N],), [N,[['unsupported',None],['unsupported',None]]])
check('contract fixture 3', solve([{'dead':[False,{'name':'secret'}]},[['missing','name'],['dead','name']],N,N],), [N,[['gone',None],['gone',None]]])
check('contract fixture 4', solve([{'a':[True,{'name':'A'}]},[['a','name'],['missing','role']],N,N-1],), [N,[['stale',None],['stale',None]]])
check('contract fixture 5', solve([{'a':[True,{'name':'A'}]},[['a','name']],N,N+1],), [N,[['stale',None]]])
check('contract fixture 6', solve([{},[],N,N],), [N,[]])
check('contract fixture 7', solve([{'z':[True,{'name':'Z'}],'a':[True,{'name':'A'}]},[['z','name'],['a','name']],N,N],), [N,[['ok','Z'],['ok','A']]])
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:
Batch accessibility property results are reordered by identifier.

Input [objects,queries,revision,expected_revision]. objects map IDs to [alive,properties]; queries [id,property]. Allowed props name,value,description,role; a missing property is unsupported while an existing None is successful null. Results retain query order and duplicates, each [status,value]; status stale for every query when revisions differ, gone for missing/defunct object, unsupported for unknown/absent property, ok otherwise. Empty queries produce empty output. Return [revision,results], actual revision always. Values are returned as JSON-compatible content; object aliasing is outside this query-only model.

split: open-access