FA-27581 / HTTP ranges / Open access
A parallel downloader splits a representation into worker ranges and rebalances idle workers: remainder bytes go one each to the leading workers · case 01
A parallel downloader splits a representation into worker ranges and rebalances idle workers: remainder bytes go one each to the leading workers.
ROOT CAUSE
The segmented-download-plan-remainder-front-loaded decision uses T=x['total'] k=x['workers'] if k<=0 or T<0: return None base,extra=divmod(T,k) w=[] start=0 for i in range(k): size=base+(1 if i<=extra else 0) if size>0: w.append([start,start+size-1]) start+=size for ev in x['events']: if ev[0]=='data': i,n=ev[1],ev[2] if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None w[i][0]+=n elif ev[0]=='steal': i=ev[1] if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue j=None for t in range(len(w)): if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t rem=w[j][1]-w[j][0]+1 if rem<2: continue cut=w[j][0]+(rem+1)//2 w[i]=[cut,w[j][1]] w[j][1]=cut-1 return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e].
VERIFIED REPAIR
Apply the bounded decision exactly: T=x['total'] k=x['workers'] if k<=0 or T<0: return None base,extra=divmod(T,k) w=[] start=0 for i in range(k): size=base+(1 if i<extra else 0) if size>0: w.append([start,start+size-1]) start+=size for ev in x['events']: if ev[0]=='data': i,n=ev[1],ev[2] if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None w[i][0]+=n elif ev[0]=='steal': i=ev[1] if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue j=None for t in range(len(w)): if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t rem=w[j][1]-w[j][0]+1 if rem<2: continue cut=w[j][0]+(rem+1)//2 w[i]=[cut,w[j][1]] w[j][1]=cut-1 return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e]
Unsuccessful approach: The partial repair uses T=x['total'] k=x['workers'] if k<=0 or T<0: return None base,extra=divmod(T,k) w=[] start=0 for i in range(k): size=base+(1 if extra and i==0 else 0) if size>0: w.append([start,start+size-1]) start+=size for ev in x['events']: if ev[0]=='data': i,n=ev[1],ev[2] if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None w[i][0]+=n elif ev[0]=='steal': i=ev[1] if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue j=None for t in range(len(w)): if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t rem=w[j][1]-w[j][0]+1 if rem<2: continue cut=w[j][0]+(rem+1)//2 w[i]=[cut,w[j][1]] w[j][1]=cut-1 return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e], which still violates the stated contract.
Case contract
x has total length, worker count and events. Initial segments follow array-split sizing: base=total//workers, the first total%workers workers get one extra byte; zero-size segments are dropped and later worker indices refer to the surviving list. Each segment is [cursor,end]. data(i,n) advances worker i by n>=0 accepted bytes; an invalid or negative index, negative n or overrun past its end returns null. steal(i) is ignored unless i is a valid finished worker; the victim is the worker with the most remaining bytes (lowest index on ties); a victim with fewer than2 remaining bytes is left alone; otherwise the victim keeps the first ceil(rem/2) bytes and the thief takes the rest. Return Range header values for unfinished workers in worker order. workers<=0 or negative total returns null.
Why this case matters
Range responses combine representation identity, conditional requests, framing, and partial-object state.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
T=x['total']
k=x['workers']
if k<=0 or T<0: return None
base,extra=divmod(T,k)
w=[]
start=0
for i in range(k):
size=base+(1 if i<=extra else 0)
if size>0: w.append([start,start+size-1])
start+=size
for ev in x['events']:
if ev[0]=='data':
i,n=ev[1],ev[2]
if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None
w[i][0]+=n
elif ev[0]=='steal':
i=ev[1]
if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue
j=None
for t in range(len(w)):
if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t
rem=w[j][1]-w[j][0]+1
if rem<2: continue
cut=w[j][0]+(rem+1)//2
w[i]=[cut,w[j][1]]
w[j][1]=cut-1
return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remainder-front-loaded fixture 0', json.loads(json.dumps(solve({'events':[],'total':11,'workers':3}))), json.loads(json.dumps(['bytes=0-3','bytes=4-7','bytes=8-10'])))
check('remainder-front-loaded fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('remainder-front-loaded fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('remainder-front-loaded fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 5', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,3]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9'])))
check('remainder-front-loaded fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 7', json.loads(json.dumps(solve({'events':[['data',0,5],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9','bytes=5-7'])))
check('remainder-front-loaded fixture 8', json.loads(json.dumps(solve({'events':[['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=0-4','bytes=5-9'])))
check('remainder-front-loaded fixture 9', json.loads(json.dumps(solve({'events':[['data',0,4],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=4-4','bytes=5-9'])))
check('remainder-front-loaded fixture 10', json.loads(json.dumps(solve({'events':[['data',0,4],['data',2,1],['steal',0]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=6-7','bytes=4-5','bytes=9-11'])))
check('remainder-front-loaded fixture 11', json.loads(json.dumps(solve({'events':[['data',2,4],['steal',2]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=0-1','bytes=4-7','bytes=2-3'])))
check('remainder-front-loaded fixture 12', json.loads(json.dumps(solve({'events':[['data',0,2],['data',1,1],['steal',0]],'total':4,'workers':2}))), json.loads(json.dumps(['bytes=3-3'])))
check('remainder-front-loaded fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 14', json.loads(json.dumps(solve({'events':[],'total':4*N,'workers':2}))), json.loads(json.dumps(["bytes=0-%d"%(2*N-1),"bytes=%d-%d"%(2*N,4*N-1)])))
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| remainder-front-loaded fixture 0 | ['bytes=0-3', 'bytes=4-7', 'bytes=8-11'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Failed |
| remainder-front-loaded fixture 1 | ['bytes=0-0', 'bytes=1-1', 'bytes=2-2'] | ['bytes=0-0', 'bytes=1-1'] | Failed |
| remainder-front-loaded fixture 2 | ['bytes=0-0'] | [] | Failed |
| remainder-front-loaded fixture 3 | None | None | Passed |
| remainder-front-loaded fixture 4 | None | None | Passed |
| remainder-front-loaded fixture 5 | ['bytes=5-5', 'bytes=9-10'] | ['bytes=8-9'] | Failed |
| remainder-front-loaded fixture 6 | None | None | Passed |
| remainder-front-loaded fixture 7 | ['bytes=5-5', 'bytes=6-10'] | ['bytes=8-9', 'bytes=5-7'] | Failed |
| remainder-front-loaded fixture 8 | ['bytes=0-5', 'bytes=6-10'] | ['bytes=0-4', 'bytes=5-9'] | Failed |
| remainder-front-loaded fixture 9 | ['bytes=4-5', 'bytes=6-10'] | ['bytes=4-4', 'bytes=5-9'] | Failed |
| remainder-front-loaded fixture 10 | ['bytes=4-4', 'bytes=5-8', 'bytes=10-12'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Failed |
| remainder-front-loaded fixture 11 | ['bytes=0-2', 'bytes=5-8', 'bytes=3-4'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Failed |
| remainder-front-loaded fixture 12 | ['bytes=2-2', 'bytes=4-4'] | ['bytes=3-3'] | Failed |
| remainder-front-loaded fixture 13 | None | None | Passed |
| remainder-front-loaded fixture 14 | ['bytes=0-2', 'bytes=3-4'] | ['bytes=0-1', 'bytes=2-3'] | Failed |
SHA-256 / 164386c2db9eebdc8a44c985f2e3b5c96141924b24f550d537fe7cd5922acb94
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
T=x['total']
k=x['workers']
if k<=0 or T<0: return None
base,extra=divmod(T,k)
w=[]
start=0
for i in range(k):
size=base+(1 if extra and i==0 else 0)
if size>0: w.append([start,start+size-1])
start+=size
for ev in x['events']:
if ev[0]=='data':
i,n=ev[1],ev[2]
if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None
w[i][0]+=n
elif ev[0]=='steal':
i=ev[1]
if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue
j=None
for t in range(len(w)):
if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t
rem=w[j][1]-w[j][0]+1
if rem<2: continue
cut=w[j][0]+(rem+1)//2
w[i]=[cut,w[j][1]]
w[j][1]=cut-1
return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remainder-front-loaded fixture 0', json.loads(json.dumps(solve({'events':[],'total':11,'workers':3}))), json.loads(json.dumps(['bytes=0-3','bytes=4-7','bytes=8-10'])))
check('remainder-front-loaded fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('remainder-front-loaded fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('remainder-front-loaded fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 5', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,3]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9'])))
check('remainder-front-loaded fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 7', json.loads(json.dumps(solve({'events':[['data',0,5],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9','bytes=5-7'])))
check('remainder-front-loaded fixture 8', json.loads(json.dumps(solve({'events':[['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=0-4','bytes=5-9'])))
check('remainder-front-loaded fixture 9', json.loads(json.dumps(solve({'events':[['data',0,4],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=4-4','bytes=5-9'])))
check('remainder-front-loaded fixture 10', json.loads(json.dumps(solve({'events':[['data',0,4],['data',2,1],['steal',0]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=6-7','bytes=4-5','bytes=9-11'])))
check('remainder-front-loaded fixture 11', json.loads(json.dumps(solve({'events':[['data',2,4],['steal',2]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=0-1','bytes=4-7','bytes=2-3'])))
check('remainder-front-loaded fixture 12', json.loads(json.dumps(solve({'events':[['data',0,2],['data',1,1],['steal',0]],'total':4,'workers':2}))), json.loads(json.dumps(['bytes=3-3'])))
check('remainder-front-loaded fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 14', json.loads(json.dumps(solve({'events':[],'total':4*N,'workers':2}))), json.loads(json.dumps(["bytes=0-%d"%(2*N-1),"bytes=%d-%d"%(2*N,4*N-1)])))
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| remainder-front-loaded fixture 0 | ['bytes=0-3', 'bytes=4-6', 'bytes=7-9'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Failed |
| remainder-front-loaded fixture 1 | ['bytes=0-0'] | ['bytes=0-0', 'bytes=1-1'] | Failed |
| remainder-front-loaded fixture 2 | [] | [] | Passed |
| remainder-front-loaded fixture 3 | None | None | Passed |
| remainder-front-loaded fixture 4 | None | None | Passed |
| remainder-front-loaded fixture 5 | ['bytes=8-9'] | ['bytes=8-9'] | Passed |
| remainder-front-loaded fixture 6 | None | None | Passed |
| remainder-front-loaded fixture 7 | ['bytes=8-9', 'bytes=5-7'] | ['bytes=8-9', 'bytes=5-7'] | Passed |
| remainder-front-loaded fixture 8 | ['bytes=0-4', 'bytes=5-9'] | ['bytes=0-4', 'bytes=5-9'] | Passed |
| remainder-front-loaded fixture 9 | ['bytes=4-4', 'bytes=5-9'] | ['bytes=4-4', 'bytes=5-9'] | Passed |
| remainder-front-loaded fixture 10 | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Passed |
| remainder-front-loaded fixture 11 | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Passed |
| remainder-front-loaded fixture 12 | ['bytes=3-3'] | ['bytes=3-3'] | Passed |
| remainder-front-loaded fixture 13 | None | None | Passed |
| remainder-front-loaded fixture 14 | ['bytes=0-1', 'bytes=2-3'] | ['bytes=0-1', 'bytes=2-3'] | Passed |
SHA-256 / 8c1d5b03453f5e2466e54192bf0c685c20c5d5fad2ead7336ef0f35d7acb69bf
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
T=x['total']
k=x['workers']
if k<=0 or T<0: return None
base,extra=divmod(T,k)
w=[]
start=0
for i in range(k):
size=base+(1 if i<extra else 0)
if size>0: w.append([start,start+size-1])
start+=size
for ev in x['events']:
if ev[0]=='data':
i,n=ev[1],ev[2]
if not 0<=i<len(w) or n<0 or w[i][0]+n>w[i][1]+1: return None
w[i][0]+=n
elif ev[0]=='steal':
i=ev[1]
if not 0<=i<len(w) or w[i][0]<=w[i][1]: continue
j=None
for t in range(len(w)):
if j is None or w[t][1]-w[t][0]>w[j][1]-w[j][0]: j=t
rem=w[j][1]-w[j][0]+1
if rem<2: continue
cut=w[j][0]+(rem+1)//2
w[i]=[cut,w[j][1]]
w[j][1]=cut-1
return ['bytes=%d-%d'%(c,e) for c,e in w if c<=e]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('remainder-front-loaded fixture 0', json.loads(json.dumps(solve({'events':[],'total':11,'workers':3}))), json.loads(json.dumps(['bytes=0-3','bytes=4-7','bytes=8-10'])))
check('remainder-front-loaded fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('remainder-front-loaded fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('remainder-front-loaded fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 5', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,3]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9'])))
check('remainder-front-loaded fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 7', json.loads(json.dumps(solve({'events':[['data',0,5],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=8-9','bytes=5-7'])))
check('remainder-front-loaded fixture 8', json.loads(json.dumps(solve({'events':[['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=0-4','bytes=5-9'])))
check('remainder-front-loaded fixture 9', json.loads(json.dumps(solve({'events':[['data',0,4],['steal',0]],'total':10,'workers':2}))), json.loads(json.dumps(['bytes=4-4','bytes=5-9'])))
check('remainder-front-loaded fixture 10', json.loads(json.dumps(solve({'events':[['data',0,4],['data',2,1],['steal',0]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=6-7','bytes=4-5','bytes=9-11'])))
check('remainder-front-loaded fixture 11', json.loads(json.dumps(solve({'events':[['data',2,4],['steal',2]],'total':12,'workers':3}))), json.loads(json.dumps(['bytes=0-1','bytes=4-7','bytes=2-3'])))
check('remainder-front-loaded fixture 12', json.loads(json.dumps(solve({'events':[['data',0,2],['data',1,1],['steal',0]],'total':4,'workers':2}))), json.loads(json.dumps(['bytes=3-3'])))
check('remainder-front-loaded fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('remainder-front-loaded fixture 14', json.loads(json.dumps(solve({'events':[],'total':4*N,'workers':2}))), json.loads(json.dumps(["bytes=0-%d"%(2*N-1),"bytes=%d-%d"%(2*N,4*N-1)])))
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| remainder-front-loaded fixture 0 | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Passed |
| remainder-front-loaded fixture 1 | ['bytes=0-0', 'bytes=1-1'] | ['bytes=0-0', 'bytes=1-1'] | Passed |
| remainder-front-loaded fixture 2 | [] | [] | Passed |
| remainder-front-loaded fixture 3 | None | None | Passed |
| remainder-front-loaded fixture 4 | None | None | Passed |
| remainder-front-loaded fixture 5 | ['bytes=8-9'] | ['bytes=8-9'] | Passed |
| remainder-front-loaded fixture 6 | None | None | Passed |
| remainder-front-loaded fixture 7 | ['bytes=8-9', 'bytes=5-7'] | ['bytes=8-9', 'bytes=5-7'] | Passed |
| remainder-front-loaded fixture 8 | ['bytes=0-4', 'bytes=5-9'] | ['bytes=0-4', 'bytes=5-9'] | Passed |
| remainder-front-loaded fixture 9 | ['bytes=4-4', 'bytes=5-9'] | ['bytes=4-4', 'bytes=5-9'] | Passed |
| remainder-front-loaded fixture 10 | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Passed |
| remainder-front-loaded fixture 11 | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Passed |
| remainder-front-loaded fixture 12 | ['bytes=3-3'] | ['bytes=3-3'] | Passed |
| remainder-front-loaded fixture 13 | None | None | Passed |
| remainder-front-loaded fixture 14 | ['bytes=0-1', 'bytes=2-3'] | ['bytes=0-1', 'bytes=2-3'] | Passed |
SHA-256 / 288b7e06d468ecb12688b9cda08c3a535939c9e7249aa154d1a76193367b2889
Verification & scope
Deterministic simplified range service, with stipulated local policies and already parsed trusted inputs; not a complete HTTP implementation. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:41:26.384554+00:00.
Case digest / 58efb7df7e349c78c71a0dee1a14ac8de9e23edf86fe569c62d706ba80321893