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

N = 1
observations = []
def solve(operation, s):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if positions else 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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:
Restoration mode.

Scroll state belongs to a history entry, not its repeated URL. Pop restores after layout, pushes start at top, explicit anchors including the empty anchor take precedence, and positions clamp to the scrollable extent. Operation restoration-mode 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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return positions
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return {}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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:
Saved position prune.

Scroll state belongs to a history entry, not its repeated URL. Pop restores after layout, pushes start at top, explicit anchors including the empty anchor take precedence, and positions clamp to the scrollable extent. Operation saved-position-prune 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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if event=='pop' else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor is not None else ('saved' if event=='pop' else 'top'))
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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:
Anchor layout gate.

Scroll state belongs to a history entry, not its repeated URL. Pop restores after layout, pushes start at top, explicit anchors including the empty anchor take precedence, and positions clamp to the scrollable extent. Operation anchor-layout-gate 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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'saved'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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):
    positions, entry, path, event, ready, anchor, height, viewport = s
    if operation == 'entry-key-lookup':
        return positions.get(entry,0)
    if operation == 'push-resets-position':
        return positions.get(entry,0) if event=='pop' else 0
    if operation == 'layout-ready-deferral':
        return positions.get(entry,0) if ready else None
    if operation == 'clamp-restored-position':
        return min(max(0,positions.get(entry,0)),max(0,height-viewport))
    if operation == 'anchor-precedes-saved-position':
        return anchor if anchor is not None else positions.get(entry,0)
    if operation == 'missing-entry-detection':
        return entry not in positions
    if operation == 'restoration-mode':
        return 'manual' if event=='pop' else 'auto'
    if operation == 'saved-position-prune':
        return {k:v for k,v in positions.items() if k!=entry}
    if operation == 'anchor-layout-gate':
        return anchor if ready and anchor is not None else None
    if operation == 'restore-command':
        return 'wait' if not ready else ('anchor' if anchor else 'saved')
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('entry-key-lookup scenario 1', solve('entry-key-lookup', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('entry-key-lookup scenario 2', solve('entry-key-lookup', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('entry-key-lookup scenario 3', solve('entry-key-lookup', ({},'e2','/a','pop',True,None,10,20)), 0)
check('entry-key-lookup scenario 4', solve('entry-key-lookup', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('entry-key-lookup scenario 5', solve('entry-key-lookup', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('entry-key-lookup scenario 6', solve('entry-key-lookup', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('push-resets-position scenario 1', solve('push-resets-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('push-resets-position scenario 2', solve('push-resets-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('push-resets-position scenario 3', solve('push-resets-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('push-resets-position scenario 4', solve('push-resets-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('push-resets-position scenario 5', solve('push-resets-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('push-resets-position scenario 6', solve('push-resets-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('layout-ready-deferral scenario 1', solve('layout-ready-deferral', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('layout-ready-deferral scenario 2', solve('layout-ready-deferral', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('layout-ready-deferral scenario 3', solve('layout-ready-deferral', ({},'e2','/a','pop',True,None,10,20)), 0)
check('layout-ready-deferral scenario 4', solve('layout-ready-deferral', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('layout-ready-deferral scenario 5', solve('layout-ready-deferral', ({'e1':-5},'e1','/b','replace',True,'',100,20)), -5)
check('layout-ready-deferral scenario 6', solve('layout-ready-deferral', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('clamp-restored-position scenario 1', solve('clamp-restored-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('clamp-restored-position scenario 2', solve('clamp-restored-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 0)
check('clamp-restored-position scenario 3', solve('clamp-restored-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('clamp-restored-position scenario 4', solve('clamp-restored-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 80)
check('clamp-restored-position scenario 5', solve('clamp-restored-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 0)
check('clamp-restored-position scenario 6', solve('clamp-restored-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 15)
check('anchor-precedes-saved-position scenario 1', solve('anchor-precedes-saved-position', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), N*10)
check('anchor-precedes-saved-position scenario 2', solve('anchor-precedes-saved-position', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-precedes-saved-position scenario 3', solve('anchor-precedes-saved-position', ({},'e2','/a','pop',True,None,10,20)), 0)
check('anchor-precedes-saved-position scenario 4', solve('anchor-precedes-saved-position', ({'e1':90},'e1','/a','pop',False,None,100,20)), 90)
check('anchor-precedes-saved-position scenario 5', solve('anchor-precedes-saved-position', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-precedes-saved-position scenario 6', solve('anchor-precedes-saved-position', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('missing-entry-detection scenario 1', solve('missing-entry-detection', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), False)
check('missing-entry-detection scenario 2', solve('missing-entry-detection', ({'e1':0},'e1','/a','push',True,'section',100,20)), False)
check('missing-entry-detection scenario 3', solve('missing-entry-detection', ({},'e2','/a','pop',True,None,10,20)), True)
check('missing-entry-detection scenario 4', solve('missing-entry-detection', ({'e1':90},'e1','/a','pop',False,None,100,20)), False)
check('missing-entry-detection scenario 5', solve('missing-entry-detection', ({'e1':-5},'e1','/b','replace',True,'',100,20)), False)
check('missing-entry-detection scenario 6', solve('missing-entry-detection', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), False)
check('restoration-mode scenario 1', solve('restoration-mode', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'manual')
check('restoration-mode scenario 2', solve('restoration-mode', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'auto')
check('restoration-mode scenario 3', solve('restoration-mode', ({},'e2','/a','pop',True,None,10,20)), 'manual')
check('restoration-mode scenario 4', solve('restoration-mode', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'manual')
check('restoration-mode scenario 5', solve('restoration-mode', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'auto')
check('restoration-mode scenario 6', solve('restoration-mode', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'manual')
check('saved-position-prune scenario 1', solve('saved-position-prune', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), {'e2':50})
check('saved-position-prune scenario 2', solve('saved-position-prune', ({'e1':0},'e1','/a','push',True,'section',100,20)), {})
check('saved-position-prune scenario 3', solve('saved-position-prune', ({},'e2','/a','pop',True,None,10,20)), {})
check('saved-position-prune scenario 4', solve('saved-position-prune', ({'e1':90},'e1','/a','pop',False,None,100,20)), {})
check('saved-position-prune scenario 5', solve('saved-position-prune', ({'e1':-5},'e1','/b','replace',True,'',100,20)), {})
check('saved-position-prune scenario 6', solve('saved-position-prune', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), {'/a':70})
check('anchor-layout-gate scenario 1', solve('anchor-layout-gate', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), None)
check('anchor-layout-gate scenario 2', solve('anchor-layout-gate', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'section')
check('anchor-layout-gate scenario 3', solve('anchor-layout-gate', ({},'e2','/a','pop',True,None,10,20)), None)
check('anchor-layout-gate scenario 4', solve('anchor-layout-gate', ({'e1':90},'e1','/a','pop',False,None,100,20)), None)
check('anchor-layout-gate scenario 5', solve('anchor-layout-gate', ({'e1':-5},'e1','/b','replace',True,'',100,20)), '')
check('anchor-layout-gate scenario 6', solve('anchor-layout-gate', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'section')
check('restore-command scenario 1', solve('restore-command', ({'e1':N*10,'e2':50},'e1','/a','pop',True,None,100,20)), 'saved')
check('restore-command scenario 2', solve('restore-command', ({'e1':0},'e1','/a','push',True,'section',100,20)), 'anchor')
check('restore-command scenario 3', solve('restore-command', ({},'e2','/a','pop',True,None,10,20)), 'saved')
check('restore-command scenario 4', solve('restore-command', ({'e1':90},'e1','/a','pop',False,None,100,20)), 'wait')
check('restore-command scenario 5', solve('restore-command', ({'e1':-5},'e1','/b','replace',True,'',100,20)), 'anchor')
check('restore-command scenario 6', solve('restore-command', ({'/a':70,'e1':15},'e1','/a','pop',True,'section',40,20)), 'anchor')
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:
Restore command.

Scroll state belongs to a history entry, not its repeated URL. Pop restores after layout, pushes start at top, explicit anchors including the empty anchor take precedence, and positions clamp to the scrollable extent. Operation restore-command 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):
    pairs, defaults, route, fragment = s
    if operation == 'repeated-values-retention':
        return list(dict(pairs).get('tag',''))
    if operation == 'empty-query-value':
        return next((v for k,v in pairs if k=='q'),defaults.get('q'))
    if operation == 'query-default-merge':
        return {**defaults,**dict(pairs)}
    if operation == 'fragment-null-preservation':
        return fragment if fragment is not None else 'absent'
    if operation == 'state-cache-key':
        return (route,tuple(pairs))
    if operation == 'remove-one-query-name':
        return [(k,v) for k,v in pairs if k!='q']
    if operation == 'first-value-precedence':
        return next((v for k,v in pairs if k=='q'),None)
    if operation == 'debug-exclusion':
        return [(k,v) for k,v in pairs if k!='debug']
    if operation == 'explicit-query-key-set':
        return sorted({k for k,v in pairs})
    if operation == 'navigation-fragment-key':
        return (route,fragment)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated-values-retention scenario 1', solve('repeated-values-retention', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ['x','y'])
check('repeated-values-retention scenario 2', solve('repeated-values-retention', ([('q','')],{'q':'default'},'/a','')), [])
check('repeated-values-retention scenario 3', solve('repeated-values-retention', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('repeated-values-retention scenario 4', solve('repeated-values-retention', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [])
check('repeated-values-retention scenario 5', solve('repeated-values-retention', ([('page','0'),('tag','x')],{},'/a',None)), ['x'])
check('repeated-values-retention scenario 6', solve('repeated-values-retention', ([('q','a'),('q','b')],{},'/b','end')), [])
check('empty-query-value scenario 1', solve('empty-query-value', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'a')
check('empty-query-value scenario 2', solve('empty-query-value', ([('q','')],{'q':'default'},'/a','')), '')
check('empty-query-value scenario 3', solve('empty-query-value', ([] ,{'q':'default','page':'1'},'/a',None)), 'default')
check('empty-query-value scenario 4', solve('empty-query-value', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), '0')
check('empty-query-value scenario 5', solve('empty-query-value', ([('page','0'),('tag','x')],{},'/a',None)), None)
check('empty-query-value scenario 6', solve('empty-query-value', ([('q','a'),('q','b')],{},'/b','end')), 'a')
check('query-default-merge scenario 1', solve('query-default-merge', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), {'q':'a','tag':'y'})
check('query-default-merge scenario 2', solve('query-default-merge', ([('q','')],{'q':'default'},'/a','')), {'q':''})
check('query-default-merge scenario 3', solve('query-default-merge', ([] ,{'q':'default','page':'1'},'/a',None)), {'q':'default','page':'1'})
check('query-default-merge scenario 4', solve('query-default-merge', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), {'q':'0','page':'2','debug':'1'})
check('query-default-merge scenario 5', solve('query-default-merge', ([('page','0'),('tag','x')],{},'/a',None)), {'page':'0','tag':'x'})
check('query-default-merge scenario 6', solve('query-default-merge', ([('q','a'),('q','b')],{},'/b','end')), {'q':'b'})
check('fragment-null-preservation scenario 1', solve('fragment-null-preservation', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'part')
check('fragment-null-preservation scenario 2', solve('fragment-null-preservation', ([('q','')],{'q':'default'},'/a','')), '')
check('fragment-null-preservation scenario 3', solve('fragment-null-preservation', ([] ,{'q':'default','page':'1'},'/a',None)), 'absent')
check('fragment-null-preservation scenario 4', solve('fragment-null-preservation', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), 'x')
check('fragment-null-preservation scenario 5', solve('fragment-null-preservation', ([('page','0'),('tag','x')],{},'/a',None)), 'absent')
check('fragment-null-preservation scenario 6', solve('fragment-null-preservation', ([('q','a'),('q','b')],{},'/b','end')), 'end')
check('state-cache-key scenario 1', solve('state-cache-key', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ('/a/'+str(N),(('q','a'),('tag','x'),('tag','y'))))
check('state-cache-key scenario 2', solve('state-cache-key', ([('q','')],{'q':'default'},'/a','')), ('/a',(('q',''),)))
check('state-cache-key scenario 3', solve('state-cache-key', ([] ,{'q':'default','page':'1'},'/a',None)), ('/a',()))
check('state-cache-key scenario 4', solve('state-cache-key', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ('/b',(('q','0'),('page','2'),('debug','1'))))
check('state-cache-key scenario 5', solve('state-cache-key', ([('page','0'),('tag','x')],{},'/a',None)), ('/a',(('page','0'),('tag','x'))))
check('state-cache-key scenario 6', solve('state-cache-key', ([('q','a'),('q','b')],{},'/b','end')), ('/b',(('q','a'),('q','b'))))
check('remove-one-query-name scenario 1', solve('remove-one-query-name', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), [('tag','x'),('tag','y')])
check('remove-one-query-name scenario 2', solve('remove-one-query-name', ([('q','')],{'q':'default'},'/a','')), [])
check('remove-one-query-name scenario 3', solve('remove-one-query-name', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('remove-one-query-name scenario 4', solve('remove-one-query-name', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [('page','2'),('debug','1')])
check('remove-one-query-name scenario 5', solve('remove-one-query-name', ([('page','0'),('tag','x')],{},'/a',None)), [('page','0'),('tag','x')])
check('remove-one-query-name scenario 6', solve('remove-one-query-name', ([('q','a'),('q','b')],{},'/b','end')), [])
check('first-value-precedence scenario 1', solve('first-value-precedence', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'a')
check('first-value-precedence scenario 2', solve('first-value-precedence', ([('q','')],{'q':'default'},'/a','')), '')
check('first-value-precedence scenario 3', solve('first-value-precedence', ([] ,{'q':'default','page':'1'},'/a',None)), None)
check('first-value-precedence scenario 4', solve('first-value-precedence', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), '0')
check('first-value-precedence scenario 5', solve('first-value-precedence', ([('page','0'),('tag','x')],{},'/a',None)), None)
check('first-value-precedence scenario 6', solve('first-value-precedence', ([('q','a'),('q','b')],{},'/b','end')), 'a')
check('debug-exclusion scenario 1', solve('debug-exclusion', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), [('q','a'),('tag','x'),('tag','y')])
check('debug-exclusion scenario 2', solve('debug-exclusion', ([('q','')],{'q':'default'},'/a','')), [('q','')])
check('debug-exclusion scenario 3', solve('debug-exclusion', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('debug-exclusion scenario 4', solve('debug-exclusion', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [('q','0'),('page','2')])
check('debug-exclusion scenario 5', solve('debug-exclusion', ([('page','0'),('tag','x')],{},'/a',None)), [('page','0'),('tag','x')])
check('debug-exclusion scenario 6', solve('debug-exclusion', ([('q','a'),('q','b')],{},'/b','end')), [('q','a'),('q','b')])
check('explicit-query-key-set scenario 1', solve('explicit-query-key-set', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ['q','tag'])
check('explicit-query-key-set scenario 2', solve('explicit-query-key-set', ([('q','')],{'q':'default'},'/a','')), ['q'])
check('explicit-query-key-set scenario 3', solve('explicit-query-key-set', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('explicit-query-key-set scenario 4', solve('explicit-query-key-set', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ['debug','page','q'])
check('explicit-query-key-set scenario 5', solve('explicit-query-key-set', ([('page','0'),('tag','x')],{},'/a',None)), ['page','tag'])
check('explicit-query-key-set scenario 6', solve('explicit-query-key-set', ([('q','a'),('q','b')],{},'/b','end')), ['q'])
check('navigation-fragment-key scenario 1', solve('navigation-fragment-key', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ('/a/'+str(N),'part'))
check('navigation-fragment-key scenario 2', solve('navigation-fragment-key', ([('q','')],{'q':'default'},'/a','')), ('/a',''))
check('navigation-fragment-key scenario 3', solve('navigation-fragment-key', ([] ,{'q':'default','page':'1'},'/a',None)), ('/a',None))
check('navigation-fragment-key scenario 4', solve('navigation-fragment-key', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ('/b','x'))
check('navigation-fragment-key scenario 5', solve('navigation-fragment-key', ([('page','0'),('tag','x')],{},'/a',None)), ('/a',None))
check('navigation-fragment-key scenario 6', solve('navigation-fragment-key', ([('q','a'),('q','b')],{},'/b','end')), ('/b','end'))
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):
    pairs, defaults, route, fragment = s
    if operation == 'repeated-values-retention':
        return [v for k,v in pairs if k=='tag'][:1]
    if operation == 'empty-query-value':
        return next((v for k,v in pairs if k=='q'),defaults.get('q'))
    if operation == 'query-default-merge':
        return {**defaults,**dict(pairs)}
    if operation == 'fragment-null-preservation':
        return fragment if fragment is not None else 'absent'
    if operation == 'state-cache-key':
        return (route,tuple(pairs))
    if operation == 'remove-one-query-name':
        return [(k,v) for k,v in pairs if k!='q']
    if operation == 'first-value-precedence':
        return next((v for k,v in pairs if k=='q'),None)
    if operation == 'debug-exclusion':
        return [(k,v) for k,v in pairs if k!='debug']
    if operation == 'explicit-query-key-set':
        return sorted({k for k,v in pairs})
    if operation == 'navigation-fragment-key':
        return (route,fragment)
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated-values-retention scenario 1', solve('repeated-values-retention', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ['x','y'])
check('repeated-values-retention scenario 2', solve('repeated-values-retention', ([('q','')],{'q':'default'},'/a','')), [])
check('repeated-values-retention scenario 3', solve('repeated-values-retention', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('repeated-values-retention scenario 4', solve('repeated-values-retention', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [])
check('repeated-values-retention scenario 5', solve('repeated-values-retention', ([('page','0'),('tag','x')],{},'/a',None)), ['x'])
check('repeated-values-retention scenario 6', solve('repeated-values-retention', ([('q','a'),('q','b')],{},'/b','end')), [])
check('empty-query-value scenario 1', solve('empty-query-value', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'a')
check('empty-query-value scenario 2', solve('empty-query-value', ([('q','')],{'q':'default'},'/a','')), '')
check('empty-query-value scenario 3', solve('empty-query-value', ([] ,{'q':'default','page':'1'},'/a',None)), 'default')
check('empty-query-value scenario 4', solve('empty-query-value', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), '0')
check('empty-query-value scenario 5', solve('empty-query-value', ([('page','0'),('tag','x')],{},'/a',None)), None)
check('empty-query-value scenario 6', solve('empty-query-value', ([('q','a'),('q','b')],{},'/b','end')), 'a')
check('query-default-merge scenario 1', solve('query-default-merge', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), {'q':'a','tag':'y'})
check('query-default-merge scenario 2', solve('query-default-merge', ([('q','')],{'q':'default'},'/a','')), {'q':''})
check('query-default-merge scenario 3', solve('query-default-merge', ([] ,{'q':'default','page':'1'},'/a',None)), {'q':'default','page':'1'})
check('query-default-merge scenario 4', solve('query-default-merge', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), {'q':'0','page':'2','debug':'1'})
check('query-default-merge scenario 5', solve('query-default-merge', ([('page','0'),('tag','x')],{},'/a',None)), {'page':'0','tag':'x'})
check('query-default-merge scenario 6', solve('query-default-merge', ([('q','a'),('q','b')],{},'/b','end')), {'q':'b'})
check('fragment-null-preservation scenario 1', solve('fragment-null-preservation', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'part')
check('fragment-null-preservation scenario 2', solve('fragment-null-preservation', ([('q','')],{'q':'default'},'/a','')), '')
check('fragment-null-preservation scenario 3', solve('fragment-null-preservation', ([] ,{'q':'default','page':'1'},'/a',None)), 'absent')
check('fragment-null-preservation scenario 4', solve('fragment-null-preservation', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), 'x')
check('fragment-null-preservation scenario 5', solve('fragment-null-preservation', ([('page','0'),('tag','x')],{},'/a',None)), 'absent')
check('fragment-null-preservation scenario 6', solve('fragment-null-preservation', ([('q','a'),('q','b')],{},'/b','end')), 'end')
check('state-cache-key scenario 1', solve('state-cache-key', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ('/a/'+str(N),(('q','a'),('tag','x'),('tag','y'))))
check('state-cache-key scenario 2', solve('state-cache-key', ([('q','')],{'q':'default'},'/a','')), ('/a',(('q',''),)))
check('state-cache-key scenario 3', solve('state-cache-key', ([] ,{'q':'default','page':'1'},'/a',None)), ('/a',()))
check('state-cache-key scenario 4', solve('state-cache-key', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ('/b',(('q','0'),('page','2'),('debug','1'))))
check('state-cache-key scenario 5', solve('state-cache-key', ([('page','0'),('tag','x')],{},'/a',None)), ('/a',(('page','0'),('tag','x'))))
check('state-cache-key scenario 6', solve('state-cache-key', ([('q','a'),('q','b')],{},'/b','end')), ('/b',(('q','a'),('q','b'))))
check('remove-one-query-name scenario 1', solve('remove-one-query-name', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), [('tag','x'),('tag','y')])
check('remove-one-query-name scenario 2', solve('remove-one-query-name', ([('q','')],{'q':'default'},'/a','')), [])
check('remove-one-query-name scenario 3', solve('remove-one-query-name', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('remove-one-query-name scenario 4', solve('remove-one-query-name', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [('page','2'),('debug','1')])
check('remove-one-query-name scenario 5', solve('remove-one-query-name', ([('page','0'),('tag','x')],{},'/a',None)), [('page','0'),('tag','x')])
check('remove-one-query-name scenario 6', solve('remove-one-query-name', ([('q','a'),('q','b')],{},'/b','end')), [])
check('first-value-precedence scenario 1', solve('first-value-precedence', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), 'a')
check('first-value-precedence scenario 2', solve('first-value-precedence', ([('q','')],{'q':'default'},'/a','')), '')
check('first-value-precedence scenario 3', solve('first-value-precedence', ([] ,{'q':'default','page':'1'},'/a',None)), None)
check('first-value-precedence scenario 4', solve('first-value-precedence', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), '0')
check('first-value-precedence scenario 5', solve('first-value-precedence', ([('page','0'),('tag','x')],{},'/a',None)), None)
check('first-value-precedence scenario 6', solve('first-value-precedence', ([('q','a'),('q','b')],{},'/b','end')), 'a')
check('debug-exclusion scenario 1', solve('debug-exclusion', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), [('q','a'),('tag','x'),('tag','y')])
check('debug-exclusion scenario 2', solve('debug-exclusion', ([('q','')],{'q':'default'},'/a','')), [('q','')])
check('debug-exclusion scenario 3', solve('debug-exclusion', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('debug-exclusion scenario 4', solve('debug-exclusion', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), [('q','0'),('page','2')])
check('debug-exclusion scenario 5', solve('debug-exclusion', ([('page','0'),('tag','x')],{},'/a',None)), [('page','0'),('tag','x')])
check('debug-exclusion scenario 6', solve('debug-exclusion', ([('q','a'),('q','b')],{},'/b','end')), [('q','a'),('q','b')])
check('explicit-query-key-set scenario 1', solve('explicit-query-key-set', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ['q','tag'])
check('explicit-query-key-set scenario 2', solve('explicit-query-key-set', ([('q','')],{'q':'default'},'/a','')), ['q'])
check('explicit-query-key-set scenario 3', solve('explicit-query-key-set', ([] ,{'q':'default','page':'1'},'/a',None)), [])
check('explicit-query-key-set scenario 4', solve('explicit-query-key-set', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ['debug','page','q'])
check('explicit-query-key-set scenario 5', solve('explicit-query-key-set', ([('page','0'),('tag','x')],{},'/a',None)), ['page','tag'])
check('explicit-query-key-set scenario 6', solve('explicit-query-key-set', ([('q','a'),('q','b')],{},'/b','end')), ['q'])
check('navigation-fragment-key scenario 1', solve('navigation-fragment-key', ([('q','a'),('tag','x'),('tag','y')],{'q':'default'},'/a/'+str(N),'part')), ('/a/'+str(N),'part'))
check('navigation-fragment-key scenario 2', solve('navigation-fragment-key', ([('q','')],{'q':'default'},'/a','')), ('/a',''))
check('navigation-fragment-key scenario 3', solve('navigation-fragment-key', ([] ,{'q':'default','page':'1'},'/a',None)), ('/a',None))
check('navigation-fragment-key scenario 4', solve('navigation-fragment-key', ([('q','0'),('page','2'),('debug','1')],{'q':'default'},'/b','x')), ('/b','x'))
check('navigation-fragment-key scenario 5', solve('navigation-fragment-key', ([('page','0'),('tag','x')],{},'/a',None)), ('/a',None))
check('navigation-fragment-key scenario 6', solve('navigation-fragment-key', ([('q','a'),('q','b')],{},'/b','end')), ('/b','end'))
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:
Repeated values retention.

This route-state adapter models already-decoded query pairs. Repeated pairs and insertion order remain significant, first occurrence is used by single-value readers, explicit empty values override defaults, and fragment absence differs from empty. Operation repeated-values-retention has the six explicit input/output oracles below.

split: open-access