FAILURE MAP
← Case archive

FA-27596 / HTTP ranges / Open access

A parallel downloader splits a representation into worker ranges and rebalances idle workers: negative worker indices are rejected rather than addressing the last worker · case 01

A parallel downloader splits a representation into worker ranges and rebalances idle workers: negative worker indices are rejected rather than addressing the last worker.

Verified by executionVariant 1 · 15 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The segmented-download-plan-worker-index-sign 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 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 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 i>=len(w) or 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 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('worker-index-sign 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('worker-index-sign fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('worker-index-sign fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('worker-index-sign fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('worker-index-sign fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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 fixtureActualExpectedOutcome
worker-index-sign fixture 0['bytes=0-3', 'bytes=4-7', 'bytes=8-10']['bytes=0-3', 'bytes=4-7', 'bytes=8-10']Passed
worker-index-sign fixture 1['bytes=0-0', 'bytes=1-1']['bytes=0-0', 'bytes=1-1']Passed
worker-index-sign fixture 2[][]Passed
worker-index-sign fixture 3NoneNonePassed
worker-index-sign fixture 4NoneNonePassed
worker-index-sign fixture 5['bytes=8-9']['bytes=8-9']Passed
worker-index-sign fixture 6['bytes=0-4', 'bytes=7-9']NoneFailed
worker-index-sign fixture 7['bytes=8-9', 'bytes=5-7']['bytes=8-9', 'bytes=5-7']Passed
worker-index-sign fixture 8['bytes=0-4', 'bytes=5-9']['bytes=0-4', 'bytes=5-9']Passed
worker-index-sign fixture 9['bytes=4-4', 'bytes=5-9']['bytes=4-4', 'bytes=5-9']Passed
worker-index-sign fixture 10['bytes=6-7', 'bytes=4-5', 'bytes=9-11']['bytes=6-7', 'bytes=4-5', 'bytes=9-11']Passed
worker-index-sign fixture 11['bytes=0-1', 'bytes=4-7', 'bytes=2-3']['bytes=0-1', 'bytes=4-7', 'bytes=2-3']Passed
worker-index-sign fixture 12['bytes=3-3']['bytes=3-3']Passed
worker-index-sign fixture 13NoneNonePassed
worker-index-sign fixture 14['bytes=0-1', 'bytes=2-3']['bytes=0-1', 'bytes=2-3']Passed

SHA-256 / 0d058d11df8139410ba0aceb99b6c6ee562f1f8e189f994d326c4a905d353234

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 i>=len(w) or 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('worker-index-sign 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('worker-index-sign fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('worker-index-sign fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('worker-index-sign fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('worker-index-sign fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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 fixtureActualExpectedOutcome
worker-index-sign fixture 0['bytes=0-3', 'bytes=4-7', 'bytes=8-10']['bytes=0-3', 'bytes=4-7', 'bytes=8-10']Passed
worker-index-sign fixture 1['bytes=0-0', 'bytes=1-1']['bytes=0-0', 'bytes=1-1']Passed
worker-index-sign fixture 2[][]Passed
worker-index-sign fixture 3NoneNonePassed
worker-index-sign fixture 4NoneNonePassed
worker-index-sign fixture 5['bytes=8-9']['bytes=8-9']Passed
worker-index-sign fixture 6['bytes=0-4', 'bytes=7-9']NoneFailed
worker-index-sign fixture 7['bytes=8-9', 'bytes=5-7']['bytes=8-9', 'bytes=5-7']Passed
worker-index-sign fixture 8['bytes=0-4', 'bytes=5-9']['bytes=0-4', 'bytes=5-9']Passed
worker-index-sign fixture 9['bytes=4-4', 'bytes=5-9']['bytes=4-4', 'bytes=5-9']Passed
worker-index-sign fixture 10['bytes=6-7', 'bytes=4-5', 'bytes=9-11']['bytes=6-7', 'bytes=4-5', 'bytes=9-11']Passed
worker-index-sign fixture 11['bytes=0-1', 'bytes=4-7', 'bytes=2-3']['bytes=0-1', 'bytes=4-7', 'bytes=2-3']Passed
worker-index-sign fixture 12['bytes=3-3']['bytes=3-3']Passed
worker-index-sign fixture 13NoneNonePassed
worker-index-sign fixture 14['bytes=0-1', 'bytes=2-3']['bytes=0-1', 'bytes=2-3']Passed

SHA-256 / b841cb8d21f820fdc5d7d9e77bee55def998b9f66905475ff5581e6c5033a6b9

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('worker-index-sign 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('worker-index-sign fixture 1', json.loads(json.dumps(solve({'events':[],'total':2,'workers':4}))), json.loads(json.dumps(['bytes=0-0','bytes=1-1'])))
check('worker-index-sign fixture 2', json.loads(json.dumps(solve({'events':[],'total':0,'workers':2}))), json.loads(json.dumps([])))
check('worker-index-sign fixture 3', json.loads(json.dumps(solve({'events':[],'total':5,'workers':0}))), json.loads(json.dumps(None)))
check('worker-index-sign fixture 4', json.loads(json.dumps(solve({'events':[['data',0,5],['data',1,6]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign fixture 6', json.loads(json.dumps(solve({'events':[['data',-1,2]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign 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('worker-index-sign fixture 13', json.loads(json.dumps(solve({'events':[['data',0,-1]],'total':10,'workers':2}))), json.loads(json.dumps(None)))
check('worker-index-sign 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 fixtureActualExpectedOutcome
worker-index-sign fixture 0['bytes=0-3', 'bytes=4-7', 'bytes=8-10']['bytes=0-3', 'bytes=4-7', 'bytes=8-10']Passed
worker-index-sign fixture 1['bytes=0-0', 'bytes=1-1']['bytes=0-0', 'bytes=1-1']Passed
worker-index-sign fixture 2[][]Passed
worker-index-sign fixture 3NoneNonePassed
worker-index-sign fixture 4NoneNonePassed
worker-index-sign fixture 5['bytes=8-9']['bytes=8-9']Passed
worker-index-sign fixture 6NoneNonePassed
worker-index-sign fixture 7['bytes=8-9', 'bytes=5-7']['bytes=8-9', 'bytes=5-7']Passed
worker-index-sign fixture 8['bytes=0-4', 'bytes=5-9']['bytes=0-4', 'bytes=5-9']Passed
worker-index-sign fixture 9['bytes=4-4', 'bytes=5-9']['bytes=4-4', 'bytes=5-9']Passed
worker-index-sign fixture 10['bytes=6-7', 'bytes=4-5', 'bytes=9-11']['bytes=6-7', 'bytes=4-5', 'bytes=9-11']Passed
worker-index-sign fixture 11['bytes=0-1', 'bytes=4-7', 'bytes=2-3']['bytes=0-1', 'bytes=4-7', 'bytes=2-3']Passed
worker-index-sign fixture 12['bytes=3-3']['bytes=3-3']Passed
worker-index-sign fixture 13NoneNonePassed
worker-index-sign fixture 14['bytes=0-1', 'bytes=2-3']['bytes=0-1', 'bytes=2-3']Passed

SHA-256 / 246f9b209b5957440c33a1e7ea562139a7dd908e71c073842e847bc9786dc629

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.466230+00:00.

Case digest / 0203b09e6684c7bd9125ec902baa50b6bda26d10a67278779daa3f2bed3b3eff