FA-27726 / HTTP ranges / Open access
A delta downloader reuses matching local blocks and fetches the rest with batched ranges: a short final remote block is fetched instead of matched against a full local block · case 01
A delta downloader reuses matching local blocks and fetches the rest with batched ranges: a short final remote block is fetched instead of matched against a full local block.
ROOT CAUSE
The delta-block-fetch-short-tail-fetch decision uses T=x['total'] B=x['block'] remote=x['remote'] if B<=0 or T<0 or len(remote)!=-(-T//B): return None where={} for j,d in enumerate(x['local']): if (j+1)*B<=x['local_total']: where.setdefault(d,j) copies=[] runs=[] for i,d in enumerate(remote): n=min(B,T-i*B) if d in where: copies.append([i*B,where[d]*B,n]) continue if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1 else: runs.append([i*B,i*B+n-1]) R=x['max_ranges'] headers=[] for k in range(0,len(runs),R): headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R])) return [copies,headers].
VERIFIED REPAIR
Apply the bounded decision exactly: T=x['total'] B=x['block'] remote=x['remote'] if B<=0 or T<0 or len(remote)!=-(-T//B): return None where={} for j,d in enumerate(x['local']): if (j+1)*B<=x['local_total']: where.setdefault(d,j) copies=[] runs=[] for i,d in enumerate(remote): n=min(B,T-i*B) if d in where and n==B: copies.append([i*B,where[d]*B,n]) continue if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1 else: runs.append([i*B,i*B+n-1]) R=x['max_ranges'] headers=[] for k in range(0,len(runs),R): headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R])) return [copies,headers]
Unsuccessful approach: The partial repair uses T=x['total'] B=x['block'] remote=x['remote'] if B<=0 or T<0 or len(remote)!=-(-T//B): return None where={} for j,d in enumerate(x['local']): if (j+1)*B<=x['local_total']: where.setdefault(d,j) copies=[] runs=[] for i,d in enumerate(remote): n=min(B,T-i*B) if d in where and n>0: copies.append([i*B,where[d]*B,n]) continue if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1 else: runs.append([i*B,i*B+n-1]) R=x['max_ranges'] headers=[] for k in range(0,len(runs),R): headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R])) return [copies,headers], which still violates the stated contract.
Case contract
x has remote total length, block size, one remote digest per block (the last block may be short), local digests per local block with the local file length, and a per-request range limit R>=1. Reject nonpositive block size, negative total, or a manifest whose count is not ceil(total/block). Only complete local blocks may be copied; a full remote block whose digest occurs at any local position is copied from the first such complete local block as [dest-offset,source-offset,length]. The short final remote block is always fetched. Missing bytes form maximal adjacent inclusive runs, sent in consecutive batches of at most R ranges. Return [copies,Range values].
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']
B=x['block']
remote=x['remote']
if B<=0 or T<0 or len(remote)!=-(-T//B): return None
where={}
for j,d in enumerate(x['local']):
if (j+1)*B<=x['local_total']: where.setdefault(d,j)
copies=[]
runs=[]
for i,d in enumerate(remote):
n=min(B,T-i*B)
if d in where:
copies.append([i*B,where[d]*B,n])
continue
if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1
else: runs.append([i*B,i*B+n-1])
R=x['max_ranges']
headers=[]
for k in range(0,len(runs),R):
headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R]))
return [copies,headers]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short-tail-fetch fixture 0', json.loads(json.dumps(solve({'block':4,'local':['b','x'],'local_total':8,'max_ranges':2,'remote':['a','b','c'],'total':10}))), json.loads(json.dumps([[[4,0,4]],['bytes=0-3,8-9']])))
check('short-tail-fetch fixture 1', json.loads(json.dumps(solve({'block':4,'local':['z','z','a'],'local_total':12,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,8,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 2', json.loads(json.dumps(solve({'block':4,'local':['t','a','b'],'local_total':12,'max_ranges':2,'remote':['a','b','t'],'total':10}))), json.loads(json.dumps([[[0,4,4],[4,8,4]],['bytes=8-9']])))
check('short-tail-fetch fixture 3', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 4', json.loads(json.dumps(solve({'block':4,'local':['k'],'local_total':4,'max_ranges':2,'remote':['a','k','b','k','c','k'],'total':24}))), json.loads(json.dumps([[[4,0,4],[12,0,4],[20,0,4]],['bytes=0-3,8-11','bytes=16-19']])))
check('short-tail-fetch fixture 5', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':10}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 6', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b','c'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 7', json.loads(json.dumps(solve({'block':4,'local':['s'],'local_total':2,'max_ranges':2,'remote':['a','s'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 8', json.loads(json.dumps(solve({'block':4,'local':['a'],'local_total':4,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,0,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 9', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':[],'total':0}))), json.loads(json.dumps([[],[]])))
check('short-tail-fetch fixture 10', json.loads(json.dumps(solve({'block':0,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 11', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':1,'remote':['a','b','c'],'total':12}))), json.loads(json.dumps([[],['bytes=0-11']])))
check('short-tail-fetch fixture 12', json.loads(json.dumps(solve({'block':4,'local':['h'],'local_total':4,'max_ranges':2,'remote':["h"]*N,'total':4*N}))), json.loads(json.dumps([[[4*i,0,4] for i in range(N)],[]])))
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 |
|---|---|---|---|
| short-tail-fetch fixture 0 | [[[4, 0, 4]], ['bytes=0-3,8-9']] | [[[4, 0, 4]], ['bytes=0-3,8-9']] | Passed |
| short-tail-fetch fixture 1 | [[[0, 8, 4]], ['bytes=4-7']] | [[[0, 8, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 2 | [[[0, 4, 4], [4, 8, 4], [8, 0, 2]], []] | [[[0, 4, 4], [4, 8, 4]], ['bytes=8-9']] | Failed |
| short-tail-fetch fixture 3 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 4 | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | Passed |
| short-tail-fetch fixture 5 | None | None | Passed |
| short-tail-fetch fixture 6 | None | None | Passed |
| short-tail-fetch fixture 7 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 8 | [[[0, 0, 4]], ['bytes=4-7']] | [[[0, 0, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 9 | [[], []] | [[], []] | Passed |
| short-tail-fetch fixture 10 | None | None | Passed |
| short-tail-fetch fixture 11 | [[], ['bytes=0-11']] | [[], ['bytes=0-11']] | Passed |
| short-tail-fetch fixture 12 | [[[0, 0, 4]], []] | [[[0, 0, 4]], []] | Passed |
SHA-256 / 3b7e2ef10288f70052bb2df4a338a4fa4fda09207aead818416cdbfe43b544a2
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']
B=x['block']
remote=x['remote']
if B<=0 or T<0 or len(remote)!=-(-T//B): return None
where={}
for j,d in enumerate(x['local']):
if (j+1)*B<=x['local_total']: where.setdefault(d,j)
copies=[]
runs=[]
for i,d in enumerate(remote):
n=min(B,T-i*B)
if d in where and n>0:
copies.append([i*B,where[d]*B,n])
continue
if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1
else: runs.append([i*B,i*B+n-1])
R=x['max_ranges']
headers=[]
for k in range(0,len(runs),R):
headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R]))
return [copies,headers]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short-tail-fetch fixture 0', json.loads(json.dumps(solve({'block':4,'local':['b','x'],'local_total':8,'max_ranges':2,'remote':['a','b','c'],'total':10}))), json.loads(json.dumps([[[4,0,4]],['bytes=0-3,8-9']])))
check('short-tail-fetch fixture 1', json.loads(json.dumps(solve({'block':4,'local':['z','z','a'],'local_total':12,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,8,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 2', json.loads(json.dumps(solve({'block':4,'local':['t','a','b'],'local_total':12,'max_ranges':2,'remote':['a','b','t'],'total':10}))), json.loads(json.dumps([[[0,4,4],[4,8,4]],['bytes=8-9']])))
check('short-tail-fetch fixture 3', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 4', json.loads(json.dumps(solve({'block':4,'local':['k'],'local_total':4,'max_ranges':2,'remote':['a','k','b','k','c','k'],'total':24}))), json.loads(json.dumps([[[4,0,4],[12,0,4],[20,0,4]],['bytes=0-3,8-11','bytes=16-19']])))
check('short-tail-fetch fixture 5', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':10}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 6', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b','c'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 7', json.loads(json.dumps(solve({'block':4,'local':['s'],'local_total':2,'max_ranges':2,'remote':['a','s'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 8', json.loads(json.dumps(solve({'block':4,'local':['a'],'local_total':4,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,0,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 9', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':[],'total':0}))), json.loads(json.dumps([[],[]])))
check('short-tail-fetch fixture 10', json.loads(json.dumps(solve({'block':0,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 11', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':1,'remote':['a','b','c'],'total':12}))), json.loads(json.dumps([[],['bytes=0-11']])))
check('short-tail-fetch fixture 12', json.loads(json.dumps(solve({'block':4,'local':['h'],'local_total':4,'max_ranges':2,'remote':["h"]*N,'total':4*N}))), json.loads(json.dumps([[[4*i,0,4] for i in range(N)],[]])))
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 |
|---|---|---|---|
| short-tail-fetch fixture 0 | [[[4, 0, 4]], ['bytes=0-3,8-9']] | [[[4, 0, 4]], ['bytes=0-3,8-9']] | Passed |
| short-tail-fetch fixture 1 | [[[0, 8, 4]], ['bytes=4-7']] | [[[0, 8, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 2 | [[[0, 4, 4], [4, 8, 4], [8, 0, 2]], []] | [[[0, 4, 4], [4, 8, 4]], ['bytes=8-9']] | Failed |
| short-tail-fetch fixture 3 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 4 | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | Passed |
| short-tail-fetch fixture 5 | None | None | Passed |
| short-tail-fetch fixture 6 | None | None | Passed |
| short-tail-fetch fixture 7 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 8 | [[[0, 0, 4]], ['bytes=4-7']] | [[[0, 0, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 9 | [[], []] | [[], []] | Passed |
| short-tail-fetch fixture 10 | None | None | Passed |
| short-tail-fetch fixture 11 | [[], ['bytes=0-11']] | [[], ['bytes=0-11']] | Passed |
| short-tail-fetch fixture 12 | [[[0, 0, 4]], []] | [[[0, 0, 4]], []] | Passed |
SHA-256 / 96a41e4297d5f36fb043676774dfc973fcb822d3f94538cfe26f84f295e39a05
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']
B=x['block']
remote=x['remote']
if B<=0 or T<0 or len(remote)!=-(-T//B): return None
where={}
for j,d in enumerate(x['local']):
if (j+1)*B<=x['local_total']: where.setdefault(d,j)
copies=[]
runs=[]
for i,d in enumerate(remote):
n=min(B,T-i*B)
if d in where and n==B:
copies.append([i*B,where[d]*B,n])
continue
if runs and runs[-1][1]==i*B-1: runs[-1][1]=i*B+n-1
else: runs.append([i*B,i*B+n-1])
R=x['max_ranges']
headers=[]
for k in range(0,len(runs),R):
headers.append('bytes='+','.join('%d-%d'%(a,b) for a,b in runs[k:k+R]))
return [copies,headers]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('short-tail-fetch fixture 0', json.loads(json.dumps(solve({'block':4,'local':['b','x'],'local_total':8,'max_ranges':2,'remote':['a','b','c'],'total':10}))), json.loads(json.dumps([[[4,0,4]],['bytes=0-3,8-9']])))
check('short-tail-fetch fixture 1', json.loads(json.dumps(solve({'block':4,'local':['z','z','a'],'local_total':12,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,8,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 2', json.loads(json.dumps(solve({'block':4,'local':['t','a','b'],'local_total':12,'max_ranges':2,'remote':['a','b','t'],'total':10}))), json.loads(json.dumps([[[0,4,4],[4,8,4]],['bytes=8-9']])))
check('short-tail-fetch fixture 3', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 4', json.loads(json.dumps(solve({'block':4,'local':['k'],'local_total':4,'max_ranges':2,'remote':['a','k','b','k','c','k'],'total':24}))), json.loads(json.dumps([[[4,0,4],[12,0,4],[20,0,4]],['bytes=0-3,8-11','bytes=16-19']])))
check('short-tail-fetch fixture 5', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':10}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 6', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b','c'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 7', json.loads(json.dumps(solve({'block':4,'local':['s'],'local_total':2,'max_ranges':2,'remote':['a','s'],'total':8}))), json.loads(json.dumps([[],['bytes=0-7']])))
check('short-tail-fetch fixture 8', json.loads(json.dumps(solve({'block':4,'local':['a'],'local_total':4,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps([[[0,0,4]],['bytes=4-7']])))
check('short-tail-fetch fixture 9', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':2,'remote':[],'total':0}))), json.loads(json.dumps([[],[]])))
check('short-tail-fetch fixture 10', json.loads(json.dumps(solve({'block':0,'local':[],'local_total':0,'max_ranges':2,'remote':['a','b'],'total':8}))), json.loads(json.dumps(None)))
check('short-tail-fetch fixture 11', json.loads(json.dumps(solve({'block':4,'local':[],'local_total':0,'max_ranges':1,'remote':['a','b','c'],'total':12}))), json.loads(json.dumps([[],['bytes=0-11']])))
check('short-tail-fetch fixture 12', json.loads(json.dumps(solve({'block':4,'local':['h'],'local_total':4,'max_ranges':2,'remote':["h"]*N,'total':4*N}))), json.loads(json.dumps([[[4*i,0,4] for i in range(N)],[]])))
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 |
|---|---|---|---|
| short-tail-fetch fixture 0 | [[[4, 0, 4]], ['bytes=0-3,8-9']] | [[[4, 0, 4]], ['bytes=0-3,8-9']] | Passed |
| short-tail-fetch fixture 1 | [[[0, 8, 4]], ['bytes=4-7']] | [[[0, 8, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 2 | [[[0, 4, 4], [4, 8, 4]], ['bytes=8-9']] | [[[0, 4, 4], [4, 8, 4]], ['bytes=8-9']] | Passed |
| short-tail-fetch fixture 3 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 4 | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | [[[4, 0, 4], [12, 0, 4], [20, 0, 4]], ['bytes=0-3,8-11', 'bytes=16-19']] | Passed |
| short-tail-fetch fixture 5 | None | None | Passed |
| short-tail-fetch fixture 6 | None | None | Passed |
| short-tail-fetch fixture 7 | [[], ['bytes=0-7']] | [[], ['bytes=0-7']] | Passed |
| short-tail-fetch fixture 8 | [[[0, 0, 4]], ['bytes=4-7']] | [[[0, 0, 4]], ['bytes=4-7']] | Passed |
| short-tail-fetch fixture 9 | [[], []] | [[], []] | Passed |
| short-tail-fetch fixture 10 | None | None | Passed |
| short-tail-fetch fixture 11 | [[], ['bytes=0-11']] | [[], ['bytes=0-11']] | Passed |
| short-tail-fetch fixture 12 | [[[0, 0, 4]], []] | [[[0, 0, 4]], []] | Passed |
SHA-256 / 6ab569b4ddee45bb53a997495abd16fb061da68a5c97b9973b17f77c0f7afe12
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:27.636848+00:00.
Case digest / a01dc7aeca56a2ec5534fc3e5b3efac759a84c885cd7d73fcd174388e296b3d2