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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation != old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation >= old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Stale create replaces a newer semantic proxy.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and True and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= -1 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative generation creates a platform proxy.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and True:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation <= old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Stale proxy handles mutate the replacement object.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy' and old[3] == 0: old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy' and old[3] < 1: old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Pinned proxies remain semantically live after destruction.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1] = False
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,''
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Destroyed proxy retains sensitive value payload.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set': old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[3] == 0: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A value update resurrects data on a defunct proxy.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin': old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[3] == 0: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Retired accessibility proxies accept new pins.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = old[3]-1
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(-1,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Extra proxy release underflows reference count.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,row) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,row if row[3] else list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Earlier proxy snapshots change after later mutation.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,old[3] if old else 0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(data):
    state = {}
    result = []
    for kind,ident,generation,value in data:
        old = state.get(ident)
        if kind == 'create' and generation >= 0 and (old is None or generation > old[0]):
            state[ident] = [generation,True,value,old[3] if old and old[1] else 0]
        elif old is not None and generation == old[0]:
            if kind == 'destroy': old[1],old[2] = False,None
            elif kind == 'set' and old[1]: old[2] = value
            elif kind == 'pin' and old[1]: old[3] += 1
            elif kind == 'unpin': old[3] = max(0,old[3]-1)
        row = state.get(ident)
        result.append((ident,list(row)) if row is not None else None)
    return [([entry[0]]+entry[1]) if entry is not None else None for entry in result]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('newer proxy preserves stale isolation', solve([['create','a',N,'x'],['create','a',N+1,'y'],['set','a',N,'stale'],['destroy','a',N,None]],), [['a',N,True,'x',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('equal generation no reset', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N,'y']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,True,'x',1]])
check('stale create and pinned generation', solve([['create','a',N,'x'],['pin','a',N,None],['create','a',N+1,'y'],['create','a',N,'stale']],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N+1,True,'y',0],['a',N+1,True,'y',0]])
check('retired proxy cannot revive', solve([['create','a',N,'x'],['destroy','a',N,None],['set','a',N,'z'],['pin','a',N,None]],), [['a',N,True,'x',0],['a',N,False,None,0],['a',N,False,None,0],['a',N,False,None,0]])
check('pinned destroy immediate', solve([['create','a',N,'x'],['pin','a',N,None],['destroy','a',N,None],['unpin','a',N,None]],), [['a',N,True,'x',0],['a',N,True,'x',1],['a',N,False,None,1],['a',N,False,None,0]])
check('unpin lower bound', solve([['create','a',0,'x'],['unpin','a',0,None],['set','a',0,'y']],), [['a',0,True,'x',0],['a',0,True,'x',0],['a',0,True,'y',0]])
check('unknown and negative', solve([['set','missing',0,'x'],['create','bad',-1,'x'],['get','missing',0,None]],), [None,None,None])
check('separate proxy IDs', solve([['create','a',N,'x'],['create','b',N,'y']],), [['a',N,True,'x',0],['b',N,True,'y',0]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
New proxy generations inherit an old pin count.

Bounded accessibility proxy registry: input operations [kind,id,generation,value]. create installs a nonnegative generation only if newer than existing generation; retired generations remain recorded. destroy only applies to matching generation. get returns value only for matching generation live proxy. set changes matching live proxy and never creates objects. pin/unpin maintain nonnegative reference count; destroying a pinned proxy immediately makes reads unavailable but keeps tombstone until unpinned. Each operation returns a snapshot [id,generation,live,value,pins] for its ID, or None when absent; dead value is always None. Unknown operations do nothing.

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible and doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unexposed headings enter document navigation metadata.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or not doc: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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:
Headings from embedded documents pollute the parent outline.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if not isinstance(level,int) or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if not isinstance(level,(int,bool)) or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Boolean attributes are interpreted as level one headings.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or False: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 0 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Out-of-domain heading levels enter the outline.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' ')
        if not text: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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:
Heading whitespace-only names create empty navigation entries.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if False: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if text is None: continue
        if ident not in chosen or order < chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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:
Nameless headings become structural ancestors.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access


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

N = 1
observations = []
def solve(data):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order > chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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):
    records,document = data
    chosen = {}
    for ident,level,text,visible,doc,order in records:
        if not visible or doc != document: continue
        if type(level) is not int or not 1 <= level <= 6: continue
        text = text.strip(' \t\r\n')
        if not text: continue
        if ident not in chosen or order <= chosen[ident][0]: chosen[ident] = (order,level,text)
    stack = []
    result = []
    for ident,(order,level,text) in sorted(chosen.items(),key=lambda pair:pair[1][0]):
        while stack and stack[-1][1] >= level: stack.pop()
        result.append([ident,level,text,stack[-1][0] if stack else None])
        stack.append((ident,level))
    return result
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('levels and sibling ancestry', solve([[['a',1,' '+'A'*N+' ',True,'d',0],['b',3,'B',True,'d',N],['c',3,'C',True,'d',N+1],['d',2,'D',True,'d',N+2],['e',1,'E',True,'d',N+3]],'d'],), [['a',1,'A'*N,None],['b',3,'B','a'],['c',3,'C','a'],['d',2,'D','a'],['e',1,'E',None]])
check('sort document order', solve([[['b',2,'B',True,'d',N+1],['a',1,'A',True,'d',N]],'d'],), [['a',1,'A',None],['b',2,'B','a']])
check('earliest duplicate', solve([[['a',2,'late',True,'d',N+1],['a',1,'first',True,'d',N],['a',3,'tie',True,'d',N]],'d'],), [['a',1,'first',None]])
check('visibility and document', solve([[['a',1,'A',False,'d',0],['b',1,'B',True,'e',1],['c',2,'C',True,'d',2]],'d'],), [['c',2,'C',None]])
check('level admission', solve([[['a',0,'A',True,'d',0],['b',7,'B',True,'d',1],['c',True,'C',True,'d',2],['z',6,'Z',True,'d',3]],'d'],), [['z',6,'Z',None]])
check('trim empty and NBSP', solve([[['a',1,' \t',True,'d',0],['b',2,'\u00a0',True,'d',1]],'d'],), [['b',2,'\u00a0',None]])
check('empty', solve([[],'d'],), [])
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:
Later duplicate heading IDs overwrite earlier document positions.

A document heading inventory receives records [id,level,text,exposed,document,order] and requested document. Admit exposed level integers 1..6 (booleans are not levels), nonempty text after ASCII trimming, exact document. For duplicate IDs retain the earliest order record; ties retain first input. Output sorted by order with each heading's nearest preceding lower-level heading ID as parent. Skipped levels do not create synthetic headings. Output [id,level,trimmed_text,parent].

split: open-access