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

N = 1
observations = []
def solve(x):
    visible=dict(x[0])
    pending=None
    reads=[]
    for event in x[1]:
        op=event[0]
        if op=='begin':
            if pending is not None: continue
            pending=[event[1],set(event[2]),{}]
        elif op=='put':
            if pending is None or event[1]!=pending[0]: continue
            at,char=event[2:]
            if at not in pending[1]: continue
            if at in pending[2] and pending[2][at]!=char:
                pending=None
                continue
            pending[2][at]=char
        elif op=='commit':
            if pending is None or event[1]!=pending[0]: continue
            if set(pending[2])!=pending[1]: continue
            visible=dict(pending[2])
            pending=None
        elif op=='abort':
            if pending is not None and event[1]==pending[0]: pending=None
        elif op=='read':
            reads.append(sorted(pending[2].items()) if pending is not None else sorted(visible.items()))
    return [reads,sorted(visible.items()),pending[0] if pending is not None else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('read-isolation fixture 0', json.loads(json.dumps(solve([[[0,'o'],[9,'z']],[['begin','a',[0,1]],['put','a',1,'b'],['read'],['put','a',0,'a'],['commit','a'],['read']]]))), json.loads(json.dumps([[[[0,'o'],[9,'z']],[[0,'a'],[1,'b']]],[[0,'a'],[1,'b']],None])))
check('read-isolation fixture 1', json.loads(json.dumps(solve([[],[['begin','a',[0,1]],['put','a',0,'a'],['commit','a'],['read']]]))), json.loads(json.dumps([[[]],[],'a'])))
check('read-isolation fixture 2', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','wrong',0,'x'],['put','a',1,'y'],['commit','a'],['read']]]))), json.loads(json.dumps([[[]],[],'a'])))
check('read-isolation fixture 3', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',1,'b'],['commit','a']]]))), json.loads(json.dumps([[],[[0,'a']],None])))
check('read-isolation fixture 4', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',0,'b'],['commit','a']]]))), json.loads(json.dumps([[],[],None])))
check('read-isolation fixture 5', json.loads(json.dumps(solve([[],[['begin','a',[0]],['begin','b',[]],['abort','b'],['put','a',0,'a'],['commit','a']]]))), json.loads(json.dumps([[],[[0,'a']],None])))
check('read-isolation fixture 6', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',0,'a'],['commit','wrong'],['read'],['commit','a']]]))), json.loads(json.dumps([[[]],[[0,'a']],None])))
check('read-isolation fixture 7', json.loads(json.dumps(solve([[],[['begin','a',[]],['commit','a'],['begin','b',[N]],['put','b',N,'p'],['commit','b']]]))), json.loads(json.dumps([[],[[N,'p']],None])))
check('read-isolation fixture 8', json.loads(json.dumps(solve([[[0,'o']],[['begin','a',[0]],['put','a',0,'a'],['abort','a'],['read']]]))), json.loads(json.dumps([[[[0,'o']]],[[0,'o']],None])))
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(x):
    visible=dict(x[0])
    pending=None
    reads=[]
    for event in x[1]:
        op=event[0]
        if op=='begin':
            if pending is not None: continue
            pending=[event[1],set(event[2]),{}]
        elif op=='put':
            if pending is None or event[1]!=pending[0]: continue
            at,char=event[2:]
            if at not in pending[1]: continue
            if at in pending[2] and pending[2][at]!=char:
                pending=None
                continue
            pending[2][at]=char
        elif op=='commit':
            if pending is None or event[1]!=pending[0]: continue
            if set(pending[2])!=pending[1]: continue
            visible=dict(pending[2])
            pending=None
        elif op=='abort':
            if pending is not None and event[1]==pending[0]: pending=None
        elif op=='read':
            reads.append(sorted((dict(visible,**{}) | pending[2]).items()) if pending is not None else sorted(visible.items()))
    return [reads,sorted(visible.items()),pending[0] if pending is not None else None]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('read-isolation fixture 0', json.loads(json.dumps(solve([[[0,'o'],[9,'z']],[['begin','a',[0,1]],['put','a',1,'b'],['read'],['put','a',0,'a'],['commit','a'],['read']]]))), json.loads(json.dumps([[[[0,'o'],[9,'z']],[[0,'a'],[1,'b']]],[[0,'a'],[1,'b']],None])))
check('read-isolation fixture 1', json.loads(json.dumps(solve([[],[['begin','a',[0,1]],['put','a',0,'a'],['commit','a'],['read']]]))), json.loads(json.dumps([[[]],[],'a'])))
check('read-isolation fixture 2', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','wrong',0,'x'],['put','a',1,'y'],['commit','a'],['read']]]))), json.loads(json.dumps([[[]],[],'a'])))
check('read-isolation fixture 3', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',1,'b'],['commit','a']]]))), json.loads(json.dumps([[],[[0,'a']],None])))
check('read-isolation fixture 4', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',0,'b'],['commit','a']]]))), json.loads(json.dumps([[],[],None])))
check('read-isolation fixture 5', json.loads(json.dumps(solve([[],[['begin','a',[0]],['begin','b',[]],['abort','b'],['put','a',0,'a'],['commit','a']]]))), json.loads(json.dumps([[],[[0,'a']],None])))
check('read-isolation fixture 6', json.loads(json.dumps(solve([[],[['begin','a',[0]],['put','a',0,'a'],['put','a',0,'a'],['commit','wrong'],['read'],['commit','a']]]))), json.loads(json.dumps([[[]],[[0,'a']],None])))
check('read-isolation fixture 7', json.loads(json.dumps(solve([[],[['begin','a',[]],['commit','a'],['begin','b',[N]],['put','b',N,'p'],['commit','b']]]))), json.loads(json.dumps([[],[[N,'p']],None])))
check('read-isolation fixture 8', json.loads(json.dumps(solve([[[0,'o']],[['begin','a',[0]],['put','a',0,'a'],['abort','a'],['read']]]))), json.loads(json.dumps([[[[0,'o']]],[[0,'o']],None])))
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:
Partial cache admission publishes complete requested fragments atomically: readers do not see an incomplete staged range generation.

x is [old-visible-cells,events]. Events begin(id,expected-offsets), put(id,offset,char), commit(id), abort(id), read. One transaction at a time; unknown or mismatching ids ignored. A conflicting duplicate byte invalidates the active transaction. Commit succeeds only when every expected cell is present and replaces the old generation. Readers see committed cells sorted by offset. Return [read-snapshots,final-cells,pending-id].

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(a))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('closed-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('closed-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('closed-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('closed-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('closed-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('closed-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('closed-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b-a))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('closed-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('closed-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('closed-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('closed-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('closed-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('closed-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('closed-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: closed selectors preserve both endpoints.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a))
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('open-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('open-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('open-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('open-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('open-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('open-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('open-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-'+str(a))
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('open-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('open-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('open-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('open-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('open-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('open-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('open-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: open selectors keep an empty final component.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append(str(a)+'-')
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('suffix-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('suffix-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('suffix-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('suffix-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('suffix-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('suffix-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('suffix-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a)) if a else None
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('suffix-format fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('suffix-format fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('suffix-format fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('suffix-format fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('suffix-format fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('suffix-format fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('suffix-format fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: suffix counts are introduced by a leading dash.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in sorted(x['selectors'],key=lambda row:row[1]):
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('member-order fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('member-order fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('member-order fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('member-order fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('member-order fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('member-order fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('member-order fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in reversed(x['selectors']):
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('member-order fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('member-order fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('member-order fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('member-order fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('member-order fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('member-order fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('member-order fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: outbound members preserve caller priority order.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+' '.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('member-separator fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('member-separator fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('member-separator fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('member-separator fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('member-separator fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('member-separator fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('member-separator fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+',bytes='.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('member-separator fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('member-separator fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('member-separator fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('member-separator fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('member-separator fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('member-separator fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('member-separator fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: multiple members share a single comma-separated field.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Content-Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('request-field-name fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('request-field-name fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('request-field-name fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('request-field-name fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('request-field-name fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('request-field-name fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('request-field-name fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Ranges','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('request-field-name fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('request-field-name fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('request-field-name fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('request-field-name fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('request-field-name fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('request-field-name fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('request-field-name fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: Range requests do not send response-only Content-Range fields.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members or x['validator'] is not None:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-request fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('empty-request fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('empty-request fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('empty-request fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('empty-request fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('empty-request fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('empty-request fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members or x['identity']:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-request fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('empty-request fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('empty-request fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('empty-request fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('empty-request fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('empty-request fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('empty-request fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: an empty selector plan emits no conditional range field.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range',value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tag-quoting fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('tag-quoting fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('tag-quoting fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('tag-quoting fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('tag-quoting fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('tag-quoting fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('tag-quoting fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' and value else value])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('tag-quoting fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('tag-quoting fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('tag-quoting fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('tag-quoting fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('tag-quoting fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('tag-quoting fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('tag-quoting fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: entity validators retain their quoted wire form.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"'])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('date-unquoted fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('date-unquoted fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('date-unquoted fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('date-unquoted fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('date-unquoted fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('date-unquoted fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('date-unquoted fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range',value if kind=='tag' else '"'+value+'"'])
    if x['identity']: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('date-unquoted fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('date-unquoted fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('date-unquoted fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('date-unquoted fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('date-unquoted fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('date-unquoted fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('date-unquoted fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: date validators are not serialized as opaque entity tags.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if False: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('identity-negotiation fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('identity-negotiation fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('identity-negotiation fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('identity-negotiation fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('identity-negotiation fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('identity-negotiation fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('identity-negotiation fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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(x):
    members=[]
    for kind,a,b in x['selectors']:
        if kind=='closed': members.append(str(a)+'-'+str(b))
        elif kind=='open': members.append(str(a)+'-')
        elif kind=='suffix': members.append('-'+str(a))
    headers=[]
    if members:
        headers.append(['Range','bytes='+','.join(members)])
        if x['validator'] is not None:
            kind,value=x['validator']
            headers.append(['If-Range','"'+value+'"' if kind=='tag' else value])
    if x['identity'] and members: headers.append(['Accept-Encoding','identity'])
    return headers
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('identity-negotiation fixture 0', json.loads(json.dumps(solve({'selectors':[['closed',0,N],['suffix',2,None]],'validator':['tag','rev'],'identity':True}))), json.loads(json.dumps([['Range',"bytes=0-"+str(N)+",-2"],['If-Range','"rev"'],['Accept-Encoding','identity']])))
check('identity-negotiation fixture 1', json.loads(json.dumps(solve({'selectors':[['open',5,None]],'validator':['date','Mon, 01 Jan 2001 00:00:00 GMT'],'identity':False}))), json.loads(json.dumps([['Range','bytes=5-'],['If-Range','Mon, 01 Jan 2001 00:00:00 GMT']])))
check('identity-negotiation fixture 2', json.loads(json.dumps(solve({'selectors':[],'validator':['tag','rev'],'identity':False}))), json.loads(json.dumps([])))
check('identity-negotiation fixture 3', json.loads(json.dumps(solve({'selectors':[['closed',9,9],['closed',0,0]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=9-9,0-0']])))
check('identity-negotiation fixture 4', json.loads(json.dumps(solve({'selectors':[['suffix',0,None]],'validator':['tag',''],'identity':False}))), json.loads(json.dumps([['Range','bytes=-0'],['If-Range','""']])))
check('identity-negotiation fixture 5', json.loads(json.dumps(solve({'selectors':[],'validator':None,'identity':True}))), json.loads(json.dumps([['Accept-Encoding','identity']])))
check('identity-negotiation fixture 6', json.loads(json.dumps(solve({'selectors':[['open',0,None]],'validator':None,'identity':False}))), json.loads(json.dumps([['Range','bytes=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 client serializes a typed range request plan: byte-stable downloads request identity when configured.

Input x contains selectors [kind,a,b], validator [tag|date,value] or null, and accept encoding policy. Closed selectors serialize a-b, open selectors a-, suffix selectors -a, in input order. Empty selectors omit Range and If-Range. Tag validators are quoted opaque ASCII strings without quotes/backslashes; dates are already formatted and remain unquoted. Identity-only policy emits Accept-Encoding identity. Return ordered [header,value] pairs.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:r[2])
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('request-sort fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('request-sort fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('request-sort fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('request-sort fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('request-sort fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('request-sort fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('request-sort fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('request-sort fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:r[0],reverse=True)
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('request-sort fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('request-sort fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('request-sort fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('request-sort fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('request-sort fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('request-sort fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('request-sort fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('request-sort fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: unsorted wire order must not drive origin coalescing.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<=b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-read fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('empty-read fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('empty-read fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('empty-read fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('empty-read fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('empty-read fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('empty-read fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('empty-read fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b or a==0]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-read fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('empty-read fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('empty-read fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('empty-read fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('empty-read fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('empty-read fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('empty-read fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('empty-read fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: empty logical selectors must not allocate backend fetches.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('gap-threshold fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('gap-threshold fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('gap-threshold fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('gap-threshold fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('gap-threshold fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('gap-threshold fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('gap-threshold fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('gap-threshold fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('gap-threshold fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('gap-threshold fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('gap-threshold fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('gap-threshold fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('gap-threshold fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('gap-threshold fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('gap-threshold fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('gap-threshold fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: reads at the configured merge gap remain eligible.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if False: merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('protected-gap fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('protected-gap fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('protected-gap fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('protected-gap fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('protected-gap fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('protected-gap fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('protected-gap fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('protected-gap fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and fetches[-1][1] in x['forbidden']: merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('protected-gap fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('protected-gap fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('protected-gap fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('protected-gap fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('protected-gap fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('protected-gap fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('protected-gap fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('protected-gap fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: coalescing cannot fetch forbidden bytes absent from requested payloads.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=b
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contained-span fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('contained-span fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('contained-span fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('contained-span fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('contained-span fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('contained-span fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('contained-span fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('contained-span fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=min(fetches[index][1],b)
        else:
            index=len(fetches)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contained-span fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('contained-span fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('contained-span fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('contained-span fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('contained-span fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('contained-span fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('contained-span fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('contained-span fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: contained requests must not shrink a larger origin read.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access


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

N = 1
observations = []
def solve(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=max(0,len(fetches)-1)
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('assignment-index fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('assignment-index fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('assignment-index fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('assignment-index fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('assignment-index fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('assignment-index fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('assignment-index fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('assignment-index fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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(x):
    rows=[(a,b,i) for i,(a,b) in enumerate(x['requests']) if a<b]
    rows.sort(key=lambda r:(r[0],r[1]))
    fetches=[]
    assignments={}
    for a,b,i in rows:
        merge=bool(fetches) and a<=fetches[-1][1]+x['gap']
        if merge and any(p in x['forbidden'] for p in range(fetches[-1][1],a)): merge=False
        if merge:
            index=len(fetches)-1
            fetches[index][1]=max(fetches[index][1],b)
        else:
            index=0
            fetches.append([a,b])
        assignments[i]=index
    mapping=[]
    for i,(a,b) in enumerate(x['requests']):
        if a==b: mapping.append(None); continue
        index=assignments[i]
        mapping.append([index,a-fetches[index][0],b-a])
    return [fetches,mapping]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('assignment-index fixture 0', json.loads(json.dumps(solve({'requests':[[4,6],[0,2]],'gap':2,'forbidden':[]}))), json.loads(json.dumps([[[0,6]],[[0,4,2],[0,0,2]]])))
check('assignment-index fixture 1', json.loads(json.dumps(solve({'requests':[[0,2],[4,6]],'gap':2,'forbidden':[3]}))), json.loads(json.dumps([[[0,2],[4,6]],[[0,0,2],[1,0,2]]])))
check('assignment-index fixture 2', json.loads(json.dumps(solve({'requests':[[0,5],[2,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,5]],[[0,0,5],[0,2,1]]])))
check('assignment-index fixture 3', json.loads(json.dumps(solve({'requests':[[0,2],[2,4]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,4]],[[0,0,2],[0,2,2]]])))
check('assignment-index fixture 4', json.loads(json.dumps(solve({'requests':[[0,0],[3,3]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[None,None]])))
check('assignment-index fixture 5', json.loads(json.dumps(solve({'requests':[[2,4],[8,9]],'gap':1,'forbidden':[]}))), json.loads(json.dumps([[[2,4],[8,9]],[[0,0,2],[1,0,1]]])))
check('assignment-index fixture 6', json.loads(json.dumps(solve({'requests':[[0,N],[N,2*N]],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[[0,2*N]],[[0,0,N],[0,N,N]]])))
check('assignment-index fixture 7', json.loads(json.dumps(solve({'requests':[],'gap':0,'forbidden':[]}))), json.loads(json.dumps([[],[]])))
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 proxy coalesces nearby requested spans into economical origin reads: new fetches map to their newly allocated index.

x contains request rows [start,stop] with half-open nonnegative bounds, a nonnegative max-gap, and a set of forbidden byte positions. Empty requests contribute no work. Sort requests by start/stop, merge overlapping or nearby reads only if the gap has no forbidden byte. Return fetch spans and, in original request order, [fetch-index,offset-within-fetch,count] mappings. Empty requests map to null. This model plans origin reads only and does not redefine inclusive wire range semantics.

split: open-access