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

N = 1
observations = []
def solve(operation, s):
    chunks, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return sum(bool(x) for x in chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    chunks, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(''.join(chunks[cursor:]))
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Empty chunk consumes position.

The client stream view tracks a chunk cursor independently from rendered text. Per-frame budgets consume chunks including empty chunks. Completion waits for drain, and cancellation preserves committed text but discards pending output. Operation empty-chunk-consumes-position 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, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[limit:]
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return []
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unconsumed tail after frame.

The client stream view tracks a chunk cursor independently from rendered text. Per-frame budgets consume chunks including empty chunks. Completion waits for drain, and cancellation preserves committed text but discards pending output. Operation unconsumed-tail-after-frame 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, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return finished
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    chunks, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return cursor==len(chunks)
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks) and limit>0
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Completion event once drained.

The client stream view tracks a chunk cursor independently from rendered text. Per-frame budgets consume chunks including empty chunks. Completion waits for drain, and cancellation preserves committed text but discards pending output. Operation completion-event-once-drained 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, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return cursor<len(chunks)
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    chunks, cursor, committed, finished, cancelled, limit = s
    if operation == 'append-only-unseen-chunks':
        return committed+''.join(chunks[cursor:])
    if operation == 'render-budget-prefix':
        return chunks[cursor:cursor+limit]
    if operation == 'cursor-advances-by-consumed-count':
        return cursor+len(chunks[cursor:cursor+limit])
    if operation == 'cancel-freezes-visible-text':
        return committed if cancelled else committed+''.join(chunks[cursor:])
    if operation == 'finished-but-buffered-state':
        return 'draining' if finished and cursor<len(chunks) else ('complete' if finished else 'streaming')
    if operation == 'empty-chunk-consumes-position':
        return len(chunks[cursor:])
    if operation == 'unconsumed-tail-after-frame':
        return chunks[cursor+limit:]
    if operation == 'completion-event-once-drained':
        return finished and cursor==len(chunks) and not cancelled
    if operation == 'render-frame-needed':
        return not cancelled and cursor<len(chunks)
    if operation == 'abort-discards-buffered-suffix':
        return [] if cancelled else chunks[cursor:]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('append-only-unseen-chunks scenario 1', solve('append-only-unseen-chunks', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('append-only-unseen-chunks scenario 2', solve('append-only-unseen-chunks', ([],0,'',True,False,2)), '')
check('append-only-unseen-chunks scenario 3', solve('append-only-unseen-chunks', (['a','b'],2,'ab',True,False,2)), 'ab')
check('append-only-unseen-chunks scenario 4', solve('append-only-unseen-chunks', (['a','b'],0,'old',False,True,1)), 'oldab')
check('append-only-unseen-chunks scenario 5', solve('append-only-unseen-chunks', (['','x'],0,'',False,False,0)), 'x')
check('append-only-unseen-chunks scenario 6', solve('append-only-unseen-chunks', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('render-budget-prefix scenario 1', solve('render-budget-prefix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('render-budget-prefix scenario 2', solve('render-budget-prefix', ([],0,'',True,False,2)), [])
check('render-budget-prefix scenario 3', solve('render-budget-prefix', (['a','b'],2,'ab',True,False,2)), [])
check('render-budget-prefix scenario 4', solve('render-budget-prefix', (['a','b'],0,'old',False,True,1)), ['a'])
check('render-budget-prefix scenario 5', solve('render-budget-prefix', (['','x'],0,'',False,False,0)), [])
check('render-budget-prefix scenario 6', solve('render-budget-prefix', (['a','b','c'],1,'a',True,False,1)), ['b'])
check('cursor-advances-by-consumed-count scenario 1', solve('cursor-advances-by-consumed-count', (['a'*N,'b','c'],1,'old',False,False,2)), 3)
check('cursor-advances-by-consumed-count scenario 2', solve('cursor-advances-by-consumed-count', ([],0,'',True,False,2)), 0)
check('cursor-advances-by-consumed-count scenario 3', solve('cursor-advances-by-consumed-count', (['a','b'],2,'ab',True,False,2)), 2)
check('cursor-advances-by-consumed-count scenario 4', solve('cursor-advances-by-consumed-count', (['a','b'],0,'old',False,True,1)), 1)
check('cursor-advances-by-consumed-count scenario 5', solve('cursor-advances-by-consumed-count', (['','x'],0,'',False,False,0)), 0)
check('cursor-advances-by-consumed-count scenario 6', solve('cursor-advances-by-consumed-count', (['a','b','c'],1,'a',True,False,1)), 2)
check('cancel-freezes-visible-text scenario 1', solve('cancel-freezes-visible-text', (['a'*N,'b','c'],1,'old',False,False,2)), 'oldbc')
check('cancel-freezes-visible-text scenario 2', solve('cancel-freezes-visible-text', ([],0,'',True,False,2)), '')
check('cancel-freezes-visible-text scenario 3', solve('cancel-freezes-visible-text', (['a','b'],2,'ab',True,False,2)), 'ab')
check('cancel-freezes-visible-text scenario 4', solve('cancel-freezes-visible-text', (['a','b'],0,'old',False,True,1)), 'old')
check('cancel-freezes-visible-text scenario 5', solve('cancel-freezes-visible-text', (['','x'],0,'',False,False,0)), 'x')
check('cancel-freezes-visible-text scenario 6', solve('cancel-freezes-visible-text', (['a','b','c'],1,'a',True,False,1)), 'abc')
check('finished-but-buffered-state scenario 1', solve('finished-but-buffered-state', (['a'*N,'b','c'],1,'old',False,False,2)), 'streaming')
check('finished-but-buffered-state scenario 2', solve('finished-but-buffered-state', ([],0,'',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 3', solve('finished-but-buffered-state', (['a','b'],2,'ab',True,False,2)), 'complete')
check('finished-but-buffered-state scenario 4', solve('finished-but-buffered-state', (['a','b'],0,'old',False,True,1)), 'streaming')
check('finished-but-buffered-state scenario 5', solve('finished-but-buffered-state', (['','x'],0,'',False,False,0)), 'streaming')
check('finished-but-buffered-state scenario 6', solve('finished-but-buffered-state', (['a','b','c'],1,'a',True,False,1)), 'draining')
check('empty-chunk-consumes-position scenario 1', solve('empty-chunk-consumes-position', (['a'*N,'b','c'],1,'old',False,False,2)), 2)
check('empty-chunk-consumes-position scenario 2', solve('empty-chunk-consumes-position', ([],0,'',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 3', solve('empty-chunk-consumes-position', (['a','b'],2,'ab',True,False,2)), 0)
check('empty-chunk-consumes-position scenario 4', solve('empty-chunk-consumes-position', (['a','b'],0,'old',False,True,1)), 2)
check('empty-chunk-consumes-position scenario 5', solve('empty-chunk-consumes-position', (['','x'],0,'',False,False,0)), 2)
check('empty-chunk-consumes-position scenario 6', solve('empty-chunk-consumes-position', (['a','b','c'],1,'a',True,False,1)), 2)
check('unconsumed-tail-after-frame scenario 1', solve('unconsumed-tail-after-frame', (['a'*N,'b','c'],1,'old',False,False,2)), [])
check('unconsumed-tail-after-frame scenario 2', solve('unconsumed-tail-after-frame', ([],0,'',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 3', solve('unconsumed-tail-after-frame', (['a','b'],2,'ab',True,False,2)), [])
check('unconsumed-tail-after-frame scenario 4', solve('unconsumed-tail-after-frame', (['a','b'],0,'old',False,True,1)), ['b'])
check('unconsumed-tail-after-frame scenario 5', solve('unconsumed-tail-after-frame', (['','x'],0,'',False,False,0)), ['','x'])
check('unconsumed-tail-after-frame scenario 6', solve('unconsumed-tail-after-frame', (['a','b','c'],1,'a',True,False,1)), ['c'])
check('completion-event-once-drained scenario 1', solve('completion-event-once-drained', (['a'*N,'b','c'],1,'old',False,False,2)), False)
check('completion-event-once-drained scenario 2', solve('completion-event-once-drained', ([],0,'',True,False,2)), True)
check('completion-event-once-drained scenario 3', solve('completion-event-once-drained', (['a','b'],2,'ab',True,False,2)), True)
check('completion-event-once-drained scenario 4', solve('completion-event-once-drained', (['a','b'],0,'old',False,True,1)), False)
check('completion-event-once-drained scenario 5', solve('completion-event-once-drained', (['','x'],0,'',False,False,0)), False)
check('completion-event-once-drained scenario 6', solve('completion-event-once-drained', (['a','b','c'],1,'a',True,False,1)), False)
check('render-frame-needed scenario 1', solve('render-frame-needed', (['a'*N,'b','c'],1,'old',False,False,2)), True)
check('render-frame-needed scenario 2', solve('render-frame-needed', ([],0,'',True,False,2)), False)
check('render-frame-needed scenario 3', solve('render-frame-needed', (['a','b'],2,'ab',True,False,2)), False)
check('render-frame-needed scenario 4', solve('render-frame-needed', (['a','b'],0,'old',False,True,1)), False)
check('render-frame-needed scenario 5', solve('render-frame-needed', (['','x'],0,'',False,False,0)), False)
check('render-frame-needed scenario 6', solve('render-frame-needed', (['a','b','c'],1,'a',True,False,1)), True)
check('abort-discards-buffered-suffix scenario 1', solve('abort-discards-buffered-suffix', (['a'*N,'b','c'],1,'old',False,False,2)), ['b','c'])
check('abort-discards-buffered-suffix scenario 2', solve('abort-discards-buffered-suffix', ([],0,'',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 3', solve('abort-discards-buffered-suffix', (['a','b'],2,'ab',True,False,2)), [])
check('abort-discards-buffered-suffix scenario 4', solve('abort-discards-buffered-suffix', (['a','b'],0,'old',False,True,1)), [])
check('abort-discards-buffered-suffix scenario 5', solve('abort-discards-buffered-suffix', (['','x'],0,'',False,False,0)), ['','x'])
check('abort-discards-buffered-suffix scenario 6', solve('abort-discards-buffered-suffix', (['a','b','c'],1,'a',True,False,1)), ['b','c'])
check('empty response still streaming before end signal: append-only-unseen-chunks', solve('append-only-unseen-chunks', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: render-budget-prefix', solve('render-budget-prefix', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: cursor-advances-by-consumed-count', solve('cursor-advances-by-consumed-count', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: cancel-freezes-visible-text', solve('cancel-freezes-visible-text', ([],0,'',False,False,1)), '')
check('empty response still streaming before end signal: finished-but-buffered-state', solve('finished-but-buffered-state', ([],0,'',False,False,1)), 'streaming')
check('empty response still streaming before end signal: empty-chunk-consumes-position', solve('empty-chunk-consumes-position', ([],0,'',False,False,1)), 0)
check('empty response still streaming before end signal: unconsumed-tail-after-frame', solve('unconsumed-tail-after-frame', ([],0,'',False,False,1)), [])
check('empty response still streaming before end signal: completion-event-once-drained', solve('completion-event-once-drained', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: render-frame-needed', solve('render-frame-needed', ([],0,'',False,False,1)), False)
check('empty response still streaming before end signal: abort-discards-buffered-suffix', solve('abort-discards-buffered-suffix', ([],0,'',False,False,1)), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Render frame needed.

The client stream view tracks a chunk cursor independently from rendered text. Per-frame budgets consume chunks including empty chunks. Completion waits for drain, and cancellation preserves committed text but discards pending output. Operation render-frame-needed has the six explicit input/output oracles below.

split: open-access