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

N = 1
observations = []
def solve(operation, s):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status!='failed'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready' and bool(subscribers)
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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:
Ready resource adoption.

A prefetch handle is keyed by route and build version, has an exclusive expiration deadline, shares pending work, and is adopted only when ready. Consumer registrations are counted, including repeated registrations. Operation ready-resource-adoption 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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='ready'
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and version==cached_version
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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:
Pending resource sharing.

A prefetch handle is keyed by route and build version, has an exclusive expiration deadline, shares pending work, and is adopted only when ready. Consumer registrations are counted, including repeated registrations. Operation pending-resource-sharing 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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return status!='ready'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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:
Unobserved cancel.

A prefetch handle is keyed by route and build version, has an exclusive expiration deadline, shares pending work, and is adopted only when ready. Consumer registrations are counted, including repeated registrations. Operation unobserved-cancel 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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(set(subscribers))
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return int(bool(subscribers))
    if operation == 'failed-prefetch-retry':
        return status=='failed'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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:
Subscriber reference count.

A prefetch handle is keyed by route and build version, has an exclusive expiration deadline, shares pending work, and is adopted only when ready. Consumer registrations are counted, including repeated registrations. Operation subscriber-reference-count 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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return False
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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):
    route, cached_route, version, cached_version, expires, now, status, subscribers = s
    if operation == 'adopt-exact-route-version':
        return route==cached_route and version==cached_version
    if operation == 'expiry-at-boundary':
        return expires is None or now<expires
    if operation == 'ready-resource-adoption':
        return status=='ready'
    if operation == 'pending-resource-sharing':
        return status=='pending' and route==cached_route
    if operation == 'unobserved-cancel':
        return not subscribers and status=='pending'
    if operation == 'subscriber-reference-count':
        return len(subscribers)
    if operation == 'failed-prefetch-retry':
        return status!='ready'
    if operation == 'prefetch-promote-consumer':
        return subscribers+['navigation']
    if operation == 'remaining-resource-life':
        return None if expires is None else max(0,expires-now)
    if operation == 'refresh-old-build':
        return version!=cached_version
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('adopt-exact-route-version scenario 1', solve('adopt-exact-route-version', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('adopt-exact-route-version scenario 2', solve('adopt-exact-route-version', ('/a','/a',1,1,10,10,'ready',[])), True)
check('adopt-exact-route-version scenario 3', solve('adopt-exact-route-version', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('adopt-exact-route-version scenario 4', solve('adopt-exact-route-version', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('adopt-exact-route-version scenario 5', solve('adopt-exact-route-version', ('/b','/b',1,1,12,10,'failed',[])), True)
check('adopt-exact-route-version scenario 6', solve('adopt-exact-route-version', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('expiry-at-boundary scenario 1', solve('expiry-at-boundary', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('expiry-at-boundary scenario 2', solve('expiry-at-boundary', ('/a','/a',1,1,10,10,'ready',[])), False)
check('expiry-at-boundary scenario 3', solve('expiry-at-boundary', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('expiry-at-boundary scenario 4', solve('expiry-at-boundary', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('expiry-at-boundary scenario 5', solve('expiry-at-boundary', ('/b','/b',1,1,12,10,'failed',[])), True)
check('expiry-at-boundary scenario 6', solve('expiry-at-boundary', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('ready-resource-adoption scenario 1', solve('ready-resource-adoption', ('/a','/a',N,N,10,9,'ready',['screen'])), True)
check('ready-resource-adoption scenario 2', solve('ready-resource-adoption', ('/a','/a',1,1,10,10,'ready',[])), True)
check('ready-resource-adoption scenario 3', solve('ready-resource-adoption', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), True)
check('ready-resource-adoption scenario 4', solve('ready-resource-adoption', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('ready-resource-adoption scenario 5', solve('ready-resource-adoption', ('/b','/b',1,1,12,10,'failed',[])), False)
check('ready-resource-adoption scenario 6', solve('ready-resource-adoption', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), True)
check('pending-resource-sharing scenario 1', solve('pending-resource-sharing', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('pending-resource-sharing scenario 2', solve('pending-resource-sharing', ('/a','/a',1,1,10,10,'ready',[])), False)
check('pending-resource-sharing scenario 3', solve('pending-resource-sharing', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('pending-resource-sharing scenario 4', solve('pending-resource-sharing', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('pending-resource-sharing scenario 5', solve('pending-resource-sharing', ('/b','/b',1,1,12,10,'failed',[])), False)
check('pending-resource-sharing scenario 6', solve('pending-resource-sharing', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('unobserved-cancel scenario 1', solve('unobserved-cancel', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('unobserved-cancel scenario 2', solve('unobserved-cancel', ('/a','/a',1,1,10,10,'ready',[])), False)
check('unobserved-cancel scenario 3', solve('unobserved-cancel', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('unobserved-cancel scenario 4', solve('unobserved-cancel', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('unobserved-cancel scenario 5', solve('unobserved-cancel', ('/b','/b',1,1,12,10,'failed',[])), False)
check('unobserved-cancel scenario 6', solve('unobserved-cancel', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('subscriber-reference-count scenario 1', solve('subscriber-reference-count', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('subscriber-reference-count scenario 2', solve('subscriber-reference-count', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('subscriber-reference-count scenario 3', solve('subscriber-reference-count', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('subscriber-reference-count scenario 4', solve('subscriber-reference-count', ('/a','/a',2,1,12,10,'pending',['screen'])), 1)
check('subscriber-reference-count scenario 5', solve('subscriber-reference-count', ('/b','/b',1,1,12,10,'failed',[])), 0)
check('subscriber-reference-count scenario 6', solve('subscriber-reference-count', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), 2)
check('failed-prefetch-retry scenario 1', solve('failed-prefetch-retry', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('failed-prefetch-retry scenario 2', solve('failed-prefetch-retry', ('/a','/a',1,1,10,10,'ready',[])), False)
check('failed-prefetch-retry scenario 3', solve('failed-prefetch-retry', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('failed-prefetch-retry scenario 4', solve('failed-prefetch-retry', ('/a','/a',2,1,12,10,'pending',['screen'])), False)
check('failed-prefetch-retry scenario 5', solve('failed-prefetch-retry', ('/b','/b',1,1,12,10,'failed',[])), True)
check('failed-prefetch-retry scenario 6', solve('failed-prefetch-retry', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
check('prefetch-promote-consumer scenario 1', solve('prefetch-promote-consumer', ('/a','/a',N,N,10,9,'ready',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 2', solve('prefetch-promote-consumer', ('/a','/a',1,1,10,10,'ready',[])), ['navigation'])
check('prefetch-promote-consumer scenario 3', solve('prefetch-promote-consumer', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), ['screen','preview','navigation'])
check('prefetch-promote-consumer scenario 4', solve('prefetch-promote-consumer', ('/a','/a',2,1,12,10,'pending',['screen'])), ['screen','navigation'])
check('prefetch-promote-consumer scenario 5', solve('prefetch-promote-consumer', ('/b','/b',1,1,12,10,'failed',[])), ['navigation'])
check('prefetch-promote-consumer scenario 6', solve('prefetch-promote-consumer', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), ['screen','screen','navigation'])
check('remaining-resource-life scenario 1', solve('remaining-resource-life', ('/a','/a',N,N,10,9,'ready',['screen'])), 1)
check('remaining-resource-life scenario 2', solve('remaining-resource-life', ('/a','/a',1,1,10,10,'ready',[])), 0)
check('remaining-resource-life scenario 3', solve('remaining-resource-life', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), 2)
check('remaining-resource-life scenario 4', solve('remaining-resource-life', ('/a','/a',2,1,12,10,'pending',['screen'])), 2)
check('remaining-resource-life scenario 5', solve('remaining-resource-life', ('/b','/b',1,1,12,10,'failed',[])), 2)
check('remaining-resource-life scenario 6', solve('remaining-resource-life', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), None)
check('refresh-old-build scenario 1', solve('refresh-old-build', ('/a','/a',N,N,10,9,'ready',['screen'])), False)
check('refresh-old-build scenario 2', solve('refresh-old-build', ('/a','/a',1,1,10,10,'ready',[])), False)
check('refresh-old-build scenario 3', solve('refresh-old-build', ('/a','/b',1,1,12,10,'ready',['screen','preview'])), False)
check('refresh-old-build scenario 4', solve('refresh-old-build', ('/a','/a',2,1,12,10,'pending',['screen'])), True)
check('refresh-old-build scenario 5', solve('refresh-old-build', ('/b','/b',1,1,12,10,'failed',[])), False)
check('refresh-old-build scenario 6', solve('refresh-old-build', ('/a','/a',1,1,None,10,'ready',['screen','screen'])), False)
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:
Failed prefetch retry.

A prefetch handle is keyed by route and build version, has an exclusive expiration deadline, shares pending work, and is adopted only when ready. Consumer registrations are counted, including repeated registrations. Operation failed-prefetch-retry has the six explicit input/output oracles below.

split: open-access