FA-27616 / HTTP ranges / Open access
A parallel downloader splits a representation into worker ranges and rebalances idle workers: the thief copies the victim end before the victim is shortened · case 01
A parallel downloader splits a representation into worker ranges and rebalances idle workers: the thief copies the victim end before the victim is shortened.
ROOT CAUSE
The segmented-download-plan-steal-assignment-order 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[j][1]=cut-1 w[i]=[cut,w[j][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 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[j][1]=cut w[i]=[cut,w[j][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[j][1]=cut-1
w[i]=[cut,w[j][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('steal-assignment-order 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('steal-assignment-order fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('steal-assignment-order fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('steal-assignment-order fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('steal-assignment-order fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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 |
|---|---|---|---|
| steal-assignment-order fixture 0 | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Passed |
| steal-assignment-order fixture 1 | ['bytes=0-0', 'bytes=1-1'] | ['bytes=0-0', 'bytes=1-1'] | Passed |
| steal-assignment-order fixture 2 | [] | [] | Passed |
| steal-assignment-order fixture 3 | None | None | Passed |
| steal-assignment-order fixture 4 | None | None | Passed |
| steal-assignment-order fixture 5 | ['bytes=8-9'] | ['bytes=8-9'] | Passed |
| steal-assignment-order fixture 6 | None | None | Passed |
| steal-assignment-order fixture 7 | ['bytes=5-7'] | ['bytes=8-9', 'bytes=5-7'] | Failed |
| steal-assignment-order fixture 8 | ['bytes=0-4', 'bytes=5-9'] | ['bytes=0-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 9 | ['bytes=4-4', 'bytes=5-9'] | ['bytes=4-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 10 | ['bytes=4-5', 'bytes=9-11'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Failed |
| steal-assignment-order fixture 11 | ['bytes=0-1', 'bytes=4-7'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Failed |
| steal-assignment-order fixture 12 | ['bytes=3-3'] | ['bytes=3-3'] | Passed |
| steal-assignment-order fixture 13 | None | None | Passed |
| steal-assignment-order fixture 14 | ['bytes=0-1', 'bytes=2-3'] | ['bytes=0-1', 'bytes=2-3'] | Passed |
SHA-256 / f6b7741bb1402967005f9e09dd91d5e671141df0507fb3d2e5fa4f6277e4738e
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 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[j][1]=cut
w[i]=[cut,w[j][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('steal-assignment-order 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('steal-assignment-order fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('steal-assignment-order fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('steal-assignment-order fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('steal-assignment-order fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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 |
|---|---|---|---|
| steal-assignment-order fixture 0 | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Passed |
| steal-assignment-order fixture 1 | ['bytes=0-0', 'bytes=1-1'] | ['bytes=0-0', 'bytes=1-1'] | Passed |
| steal-assignment-order fixture 2 | [] | [] | Passed |
| steal-assignment-order fixture 3 | None | None | Passed |
| steal-assignment-order fixture 4 | None | None | Passed |
| steal-assignment-order fixture 5 | ['bytes=8-9'] | ['bytes=8-9'] | Passed |
| steal-assignment-order fixture 6 | None | None | Passed |
| steal-assignment-order fixture 7 | ['bytes=8-8', 'bytes=5-8'] | ['bytes=8-9', 'bytes=5-7'] | Failed |
| steal-assignment-order fixture 8 | ['bytes=0-4', 'bytes=5-9'] | ['bytes=0-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 9 | ['bytes=4-4', 'bytes=5-9'] | ['bytes=4-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 10 | ['bytes=6-6', 'bytes=4-6', 'bytes=9-11'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Failed |
| steal-assignment-order fixture 11 | ['bytes=0-2', 'bytes=4-7', 'bytes=2-2'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Failed |
| steal-assignment-order fixture 12 | ['bytes=3-3'] | ['bytes=3-3'] | Passed |
| steal-assignment-order fixture 13 | None | None | Passed |
| steal-assignment-order fixture 14 | ['bytes=0-1', 'bytes=2-3'] | ['bytes=0-1', 'bytes=2-3'] | Passed |
SHA-256 / a1f5c82237c92b3555b0508913609e77faf6089d188e942668ef45aee87e7a0d
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('steal-assignment-order 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('steal-assignment-order fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('steal-assignment-order fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('steal-assignment-order fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('steal-assignment-order fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order 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('steal-assignment-order fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('steal-assignment-order 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 |
|---|---|---|---|
| steal-assignment-order fixture 0 | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | ['bytes=0-3', 'bytes=4-7', 'bytes=8-10'] | Passed |
| steal-assignment-order fixture 1 | ['bytes=0-0', 'bytes=1-1'] | ['bytes=0-0', 'bytes=1-1'] | Passed |
| steal-assignment-order fixture 2 | [] | [] | Passed |
| steal-assignment-order fixture 3 | None | None | Passed |
| steal-assignment-order fixture 4 | None | None | Passed |
| steal-assignment-order fixture 5 | ['bytes=8-9'] | ['bytes=8-9'] | Passed |
| steal-assignment-order fixture 6 | None | None | Passed |
| steal-assignment-order fixture 7 | ['bytes=8-9', 'bytes=5-7'] | ['bytes=8-9', 'bytes=5-7'] | Passed |
| steal-assignment-order fixture 8 | ['bytes=0-4', 'bytes=5-9'] | ['bytes=0-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 9 | ['bytes=4-4', 'bytes=5-9'] | ['bytes=4-4', 'bytes=5-9'] | Passed |
| steal-assignment-order fixture 10 | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | ['bytes=6-7', 'bytes=4-5', 'bytes=9-11'] | Passed |
| steal-assignment-order fixture 11 | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | ['bytes=0-1', 'bytes=4-7', 'bytes=2-3'] | Passed |
| steal-assignment-order fixture 12 | ['bytes=3-3'] | ['bytes=3-3'] | Passed |
| steal-assignment-order fixture 13 | None | None | Passed |
| steal-assignment-order fixture 14 | ['bytes=0-1', 'bytes=2-3'] | ['bytes=0-1', 'bytes=2-3'] | Passed |
SHA-256 / 77d5f571f007ff55fe74700c00e8f70514c40f0dded4b1a54f768b1cddb39ebd
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.595947+00:00.
Case digest / 3310ef29d19992f657d852d31a24fd6eb72b82fb6b952869571fba42bf35635e