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

N = 1
observations = []
def solve(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' else 'wait'
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'retry' if status=='failed' else 'save'
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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:
Download action status.

The generated-file client tracks received chunk indexes, byte counts, blob readers and user gestures. Assembly uses chunk order, ready empty files remain valid, and save actions require a current gesture. Operation download-action-status has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return []
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return list(range(len(received),len(chunks)))
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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:
Missing part display.

The generated-file client tracks received chunk indexes, byte counts, blob readers and user gestures. Assembly uses chunk order, ready empty files remain valid, and save actions require a current gesture. Operation missing-part-display has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return expected
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return expected-len(received)
    if operation == 'complete-empty-download':
        return status=='ready' and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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:
Remaining download bytes.

The generated-file client tracks received chunk indexes, byte counts, blob readers and user gestures. Assembly uses chunk order, ready empty files remain valid, and save actions require a current gesture. Operation remaining-download-bytes has the six explicit input/output oracles below.

split: open-access


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

N = 1
observations = []
def solve(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return bool(chunks) and len(received)==len(chunks)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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(operation, s):
    chunks, received, expected, status, gesture, blob, readers, detached = s
    if operation == 'received-byte-accounting':
        return sum(len(chunks[i]) for i in received)
    if operation == 'file-assembly-part-order':
        return ''.join(chunks[i] for i in sorted(received))
    if operation == 'save-requires-current-gesture':
        return status=='ready' and gesture
    if operation == 'size-mismatch-error':
        return status=='ready' and sum(len(chunks[i]) for i in received)!=expected
    if operation == 'blob-reader-reference-release':
        return blob if detached and not readers else None
    if operation == 'reader-registry-preservation':
        return list(readers)
    if operation == 'download-action-status':
        return 'save' if status=='ready' and gesture else ('retry' if status=='failed' else 'wait')
    if operation == 'missing-part-display':
        return [i for i in range(len(chunks)) if i not in received]
    if operation == 'remaining-download-bytes':
        return max(0,expected-sum(len(chunks[i]) for i in received))
    if operation == 'complete-empty-download':
        return status=='ready' and all(chunks[i] for i in received)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('received-byte-accounting scenario 1', solve('received-byte-accounting', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), N+2)
check('received-byte-accounting scenario 2', solve('received-byte-accounting', ([],[],0,'ready',False,None,[],False)), 0)
check('received-byte-accounting scenario 3', solve('received-byte-accounting', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('received-byte-accounting scenario 4', solve('received-byte-accounting', (['x'],[0],1,'ready',False,'blob:b',[],True)), 1)
check('received-byte-accounting scenario 5', solve('received-byte-accounting', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 2)
check('received-byte-accounting scenario 6', solve('received-byte-accounting', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 1)
check('file-assembly-part-order scenario 1', solve('file-assembly-part-order', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'a'*N+'bc')
check('file-assembly-part-order scenario 2', solve('file-assembly-part-order', ([],[],0,'ready',False,None,[],False)), '')
check('file-assembly-part-order scenario 3', solve('file-assembly-part-order', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'cd')
check('file-assembly-part-order scenario 4', solve('file-assembly-part-order', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'x')
check('file-assembly-part-order scenario 5', solve('file-assembly-part-order', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'ab')
check('file-assembly-part-order scenario 6', solve('file-assembly-part-order', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'z')
check('save-requires-current-gesture scenario 1', solve('save-requires-current-gesture', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('save-requires-current-gesture scenario 2', solve('save-requires-current-gesture', ([],[],0,'ready',False,None,[],False)), False)
check('save-requires-current-gesture scenario 3', solve('save-requires-current-gesture', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('save-requires-current-gesture scenario 4', solve('save-requires-current-gesture', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('save-requires-current-gesture scenario 5', solve('save-requires-current-gesture', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('save-requires-current-gesture scenario 6', solve('save-requires-current-gesture', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('size-mismatch-error scenario 1', solve('size-mismatch-error', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), False)
check('size-mismatch-error scenario 2', solve('size-mismatch-error', ([],[],0,'ready',False,None,[],False)), False)
check('size-mismatch-error scenario 3', solve('size-mismatch-error', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('size-mismatch-error scenario 4', solve('size-mismatch-error', (['x'],[0],1,'ready',False,'blob:b',[],True)), False)
check('size-mismatch-error scenario 5', solve('size-mismatch-error', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('size-mismatch-error scenario 6', solve('size-mismatch-error', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), False)
check('blob-reader-reference-release scenario 1', solve('blob-reader-reference-release', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), None)
check('blob-reader-reference-release scenario 2', solve('blob-reader-reference-release', ([],[],0,'ready',False,None,[],False)), None)
check('blob-reader-reference-release scenario 3', solve('blob-reader-reference-release', (['ab','cd'],[1],4,'loading',True,None,[],False)), None)
check('blob-reader-reference-release scenario 4', solve('blob-reader-reference-release', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'blob:b')
check('blob-reader-reference-release scenario 5', solve('blob-reader-reference-release', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), None)
check('blob-reader-reference-release scenario 6', solve('blob-reader-reference-release', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), None)
check('reader-registry-preservation scenario 1', solve('reader-registry-preservation', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), ['preview'])
check('reader-registry-preservation scenario 2', solve('reader-registry-preservation', ([],[],0,'ready',False,None,[],False)), [])
check('reader-registry-preservation scenario 3', solve('reader-registry-preservation', (['ab','cd'],[1],4,'loading',True,None,[],False)), [])
check('reader-registry-preservation scenario 4', solve('reader-registry-preservation', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('reader-registry-preservation scenario 5', solve('reader-registry-preservation', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), ['preview','save'])
check('reader-registry-preservation scenario 6', solve('reader-registry-preservation', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('download-action-status scenario 1', solve('download-action-status', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 'save')
check('download-action-status scenario 2', solve('download-action-status', ([],[],0,'ready',False,None,[],False)), 'wait')
check('download-action-status scenario 3', solve('download-action-status', (['ab','cd'],[1],4,'loading',True,None,[],False)), 'wait')
check('download-action-status scenario 4', solve('download-action-status', (['x'],[0],1,'ready',False,'blob:b',[],True)), 'wait')
check('download-action-status scenario 5', solve('download-action-status', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 'retry')
check('download-action-status scenario 6', solve('download-action-status', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 'save')
check('missing-part-display scenario 1', solve('missing-part-display', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), [])
check('missing-part-display scenario 2', solve('missing-part-display', ([],[],0,'ready',False,None,[],False)), [])
check('missing-part-display scenario 3', solve('missing-part-display', (['ab','cd'],[1],4,'loading',True,None,[],False)), [0])
check('missing-part-display scenario 4', solve('missing-part-display', (['x'],[0],1,'ready',False,'blob:b',[],True)), [])
check('missing-part-display scenario 5', solve('missing-part-display', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), [])
check('missing-part-display scenario 6', solve('missing-part-display', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), [])
check('remaining-download-bytes scenario 1', solve('remaining-download-bytes', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), 0)
check('remaining-download-bytes scenario 2', solve('remaining-download-bytes', ([],[],0,'ready',False,None,[],False)), 0)
check('remaining-download-bytes scenario 3', solve('remaining-download-bytes', (['ab','cd'],[1],4,'loading',True,None,[],False)), 2)
check('remaining-download-bytes scenario 4', solve('remaining-download-bytes', (['x'],[0],1,'ready',False,'blob:b',[],True)), 0)
check('remaining-download-bytes scenario 5', solve('remaining-download-bytes', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), 1)
check('remaining-download-bytes scenario 6', solve('remaining-download-bytes', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), 0)
check('complete-empty-download scenario 1', solve('complete-empty-download', (['a'*N,'bc'],[0,1],N+2,'ready',True,'blob:a',['preview'],False)), True)
check('complete-empty-download scenario 2', solve('complete-empty-download', ([],[],0,'ready',False,None,[],False)), True)
check('complete-empty-download scenario 3', solve('complete-empty-download', (['ab','cd'],[1],4,'loading',True,None,[],False)), False)
check('complete-empty-download scenario 4', solve('complete-empty-download', (['x'],[0],1,'ready',False,'blob:b',[],True)), True)
check('complete-empty-download scenario 5', solve('complete-empty-download', (['ab'],[0],3,'failed',True,'blob:c',['preview','save'],False)), False)
check('complete-empty-download scenario 6', solve('complete-empty-download', (['','z'],[0,1],1,'ready',True,'blob:d',[],False)), True)
check('save reader outlives preview detachment: received-byte-accounting', solve('received-byte-accounting', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 1)
check('save reader outlives preview detachment: file-assembly-part-order', solve('file-assembly-part-order', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'x')
check('save reader outlives preview detachment: save-requires-current-gesture', solve('save-requires-current-gesture', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
check('save reader outlives preview detachment: size-mismatch-error', solve('size-mismatch-error', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), False)
check('save reader outlives preview detachment: blob-reader-reference-release', solve('blob-reader-reference-release', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), None)
check('save reader outlives preview detachment: reader-registry-preservation', solve('reader-registry-preservation', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), ['save'])
check('save reader outlives preview detachment: download-action-status', solve('download-action-status', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 'save')
check('save reader outlives preview detachment: missing-part-display', solve('missing-part-display', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), [])
check('save reader outlives preview detachment: remaining-download-bytes', solve('remaining-download-bytes', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), 0)
check('save reader outlives preview detachment: complete-empty-download', solve('complete-empty-download', (['x'],[0],1,'ready',True,'blob:z',['save'],True)), True)
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:
Complete empty download.

The generated-file client tracks received chunk indexes, byte counts, blob readers and user gestures. Assembly uses chunk order, ready empty files remain valid, and save actions require a current gesture. Operation complete-empty-download has the six explicit input/output oracles below.

split: open-access