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

N = 1
observations = []
def solve(operation, s):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(draft)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return {**draft,**server}
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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:
Discard restores server.

A saved draft holds explicit dirty fields and tombstones. Restore untouched server fields, retain local null values, flag dirty fields changed against newer server data, and export only surviving dirty fields. Operation discard-restores-server 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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return draft
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft}
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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:
Edited field export.

A saved draft holds explicit dirty fields and tombstones. Restore untouched server fields, retain local null values, flag dirty fields changed against newer server data, and export only surviving dirty fields. Operation edited-field-export 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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'review' if dirty else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Restoration review.

A saved draft holds explicit dirty fields and tombstones. Restore untouched server fields, retain local null values, flag dirty fields changed against newer server data, and export only surviving dirty fields. Operation restoration-review 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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return deleted
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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):
    draft, server, dirty, saved_revision, server_revision, deleted = s
    if operation == 'restore-dirty-fields':
        return {**server,**{k:v for k,v in draft.items() if k in dirty}}
    if operation == 'deletion-overlay':
        return {k:v for k,v in draft.items() if k not in deleted}
    if operation == 'conflict-fields':
        return [k for k in dirty if k in server and draft.get(k)!=server[k]]
    if operation == 'server-advance-warning':
        return server_revision>saved_revision and bool(dirty)
    if operation == 'clean-draft-expiry':
        return not dirty and not deleted
    if operation == 'restore-added-fields':
        return {k:v for k,v in draft.items() if k not in server}
    if operation == 'discard-restores-server':
        return dict(server)
    if operation == 'edited-field-export':
        return {k:draft[k] for k in dirty if k in draft and k not in deleted}
    if operation == 'restoration-review':
        return 'review' if dirty and server_revision>saved_revision else 'restore'
    if operation == 'known-deletion-list':
        return [k for k in deleted if k not in server]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('restore-dirty-fields scenario 1', solve('restore-dirty-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':3})
check('restore-dirty-fields scenario 2', solve('restore-dirty-fields', ({}, {'a':N},[],2,2,[])), {'a':N})
check('restore-dirty-fields scenario 3', solve('restore-dirty-fields', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('restore-dirty-fields scenario 4', solve('restore-dirty-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0,'b':N})
check('restore-dirty-fields scenario 5', solve('restore-dirty-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-dirty-fields scenario 6', solve('restore-dirty-fields', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('deletion-overlay scenario 1', solve('deletion-overlay', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N,'b':2})
check('deletion-overlay scenario 2', solve('deletion-overlay', ({}, {'a':N},[],2,2,[])), {})
check('deletion-overlay scenario 3', solve('deletion-overlay', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('deletion-overlay scenario 4', solve('deletion-overlay', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('deletion-overlay scenario 5', solve('deletion-overlay', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('deletion-overlay scenario 6', solve('deletion-overlay', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('conflict-fields scenario 1', solve('conflict-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), ['a'])
check('conflict-fields scenario 2', solve('conflict-fields', ({}, {'a':N},[],2,2,[])), [])
check('conflict-fields scenario 3', solve('conflict-fields', ({'a':None},{'a':0},['a'],2,1,[])), ['a'])
check('conflict-fields scenario 4', solve('conflict-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), (['a'] if N==2 else ['a','b']))
check('conflict-fields scenario 5', solve('conflict-fields', ({'a':N},{},['a'],0,0,[])), [])
check('conflict-fields scenario 6', solve('conflict-fields', ({'a':N},{'a':N},[],1,1,['x'])), [])
check('server-advance-warning scenario 1', solve('server-advance-warning', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), True)
check('server-advance-warning scenario 2', solve('server-advance-warning', ({}, {'a':N},[],2,2,[])), False)
check('server-advance-warning scenario 3', solve('server-advance-warning', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('server-advance-warning scenario 4', solve('server-advance-warning', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), True)
check('server-advance-warning scenario 5', solve('server-advance-warning', ({'a':N},{},['a'],0,0,[])), False)
check('server-advance-warning scenario 6', solve('server-advance-warning', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('clean-draft-expiry scenario 1', solve('clean-draft-expiry', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), False)
check('clean-draft-expiry scenario 2', solve('clean-draft-expiry', ({}, {'a':N},[],2,2,[])), True)
check('clean-draft-expiry scenario 3', solve('clean-draft-expiry', ({'a':None},{'a':0},['a'],2,1,[])), False)
check('clean-draft-expiry scenario 4', solve('clean-draft-expiry', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), False)
check('clean-draft-expiry scenario 5', solve('clean-draft-expiry', ({'a':N},{},['a'],0,0,[])), False)
check('clean-draft-expiry scenario 6', solve('clean-draft-expiry', ({'a':N},{'a':N},[],1,1,['x'])), False)
check('restore-added-fields scenario 1', solve('restore-added-fields', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {})
check('restore-added-fields scenario 2', solve('restore-added-fields', ({}, {'a':N},[],2,2,[])), {})
check('restore-added-fields scenario 3', solve('restore-added-fields', ({'a':None},{'a':0},['a'],2,1,[])), {})
check('restore-added-fields scenario 4', solve('restore-added-fields', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {})
check('restore-added-fields scenario 5', solve('restore-added-fields', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('restore-added-fields scenario 6', solve('restore-added-fields', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('discard-restores-server scenario 1', solve('discard-restores-server', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':0,'b':3})
check('discard-restores-server scenario 2', solve('discard-restores-server', ({}, {'a':N},[],2,2,[])), {'a':N})
check('discard-restores-server scenario 3', solve('discard-restores-server', ({'a':None},{'a':0},['a'],2,1,[])), {'a':0})
check('discard-restores-server scenario 4', solve('discard-restores-server', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':1,'b':2})
check('discard-restores-server scenario 5', solve('discard-restores-server', ({'a':N},{},['a'],0,0,[])), {})
check('discard-restores-server scenario 6', solve('discard-restores-server', ({'a':N},{'a':N},[],1,1,['x'])), {'a':N})
check('edited-field-export scenario 1', solve('edited-field-export', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), {'a':N})
check('edited-field-export scenario 2', solve('edited-field-export', ({}, {'a':N},[],2,2,[])), {})
check('edited-field-export scenario 3', solve('edited-field-export', ({'a':None},{'a':0},['a'],2,1,[])), {'a':None})
check('edited-field-export scenario 4', solve('edited-field-export', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), {'a':0})
check('edited-field-export scenario 5', solve('edited-field-export', ({'a':N},{},['a'],0,0,[])), {'a':N})
check('edited-field-export scenario 6', solve('edited-field-export', ({'a':N},{'a':N},[],1,1,['x'])), {})
check('restoration-review scenario 1', solve('restoration-review', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), 'review')
check('restoration-review scenario 2', solve('restoration-review', ({}, {'a':N},[],2,2,[])), 'restore')
check('restoration-review scenario 3', solve('restoration-review', ({'a':None},{'a':0},['a'],2,1,[])), 'restore')
check('restoration-review scenario 4', solve('restoration-review', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), 'review')
check('restoration-review scenario 5', solve('restoration-review', ({'a':N},{},['a'],0,0,[])), 'restore')
check('restoration-review scenario 6', solve('restoration-review', ({'a':N},{'a':N},[],1,1,['x'])), 'restore')
check('known-deletion-list scenario 1', solve('known-deletion-list', ({'a':N,'b':2},{'a':0,'b':3},['a'],1,2,[])), [])
check('known-deletion-list scenario 2', solve('known-deletion-list', ({}, {'a':N},[],2,2,[])), [])
check('known-deletion-list scenario 3', solve('known-deletion-list', ({'a':None},{'a':0},['a'],2,1,[])), [])
check('known-deletion-list scenario 4', solve('known-deletion-list', ({'a':0,'b':N},{'a':1,'b':2},['a','b'],1,3,['b'])), ['b'])
check('known-deletion-list scenario 5', solve('known-deletion-list', ({'a':N},{},['a'],0,0,[])), [])
check('known-deletion-list scenario 6', solve('known-deletion-list', ({'a':N},{'a':N},[],1,1,['x'])), [])
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:
Known deletion list.

A saved draft holds explicit dirty fields and tombstones. Restore untouched server fields, retain local null values, flag dirty fields changed against newer server data, and export only surviving dirty fields. Operation known-deletion-list 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):
    dirty, target, current, pending, decision, bypass, replace = s
    if operation == 'dirty-transition-gate':
        return dirty
    if operation == 'cancel-retains-location':
        return current if decision=='cancel' else target
    if operation == 'confirm-original-destination':
        return pending if decision=='confirm' and pending is not None else current
    if operation == 'pending-request-replacement':
        return target if decision=='ask' and dirty and not bypass else None
    if operation == 'clear-on-cancel':
        return None if decision=='cancel' else pending
    if operation == 'replace-navigation-mode':
        return 'replace' if replace else 'push'
    if operation == 'same-location-noop':
        return target==current
    if operation == 'one-shot-bypass-consumption':
        return False if bypass and target!=current else bypass
    if operation == 'prompt-visibility':
        return decision=='ask' and dirty and not bypass and target!=current
    if operation == 'discard-only-after-confirm':
        return dirty and decision!='confirm'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-transition-gate scenario 1', solve('dirty-transition-gate', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('dirty-transition-gate scenario 2', solve('dirty-transition-gate', (False,'/a','/a','/old','ask',False,True)), False)
check('dirty-transition-gate scenario 3', solve('dirty-transition-gate', (True,'/b','/a','/b','cancel',False,False)), True)
check('dirty-transition-gate scenario 4', solve('dirty-transition-gate', (True,'/c','/a','/b','confirm',False,True)), True)
check('dirty-transition-gate scenario 5', solve('dirty-transition-gate', (True,'/b','/a',None,'ask',True,False)), False)
check('dirty-transition-gate scenario 6', solve('dirty-transition-gate', (False,'/b','/a',None,'ask',False,False)), False)
check('cancel-retains-location scenario 1', solve('cancel-retains-location', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/b'+str(N))
check('cancel-retains-location scenario 2', solve('cancel-retains-location', (False,'/a','/a','/old','ask',False,True)), '/a')
check('cancel-retains-location scenario 3', solve('cancel-retains-location', (True,'/b','/a','/b','cancel',False,False)), '/a')
check('cancel-retains-location scenario 4', solve('cancel-retains-location', (True,'/c','/a','/b','confirm',False,True)), '/c')
check('cancel-retains-location scenario 5', solve('cancel-retains-location', (True,'/b','/a',None,'ask',True,False)), '/b')
check('cancel-retains-location scenario 6', solve('cancel-retains-location', (False,'/b','/a',None,'ask',False,False)), '/b')
check('confirm-original-destination scenario 1', solve('confirm-original-destination', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/a')
check('confirm-original-destination scenario 2', solve('confirm-original-destination', (False,'/a','/a','/old','ask',False,True)), '/a')
check('confirm-original-destination scenario 3', solve('confirm-original-destination', (True,'/b','/a','/b','cancel',False,False)), '/a')
check('confirm-original-destination scenario 4', solve('confirm-original-destination', (True,'/c','/a','/b','confirm',False,True)), '/b')
check('confirm-original-destination scenario 5', solve('confirm-original-destination', (True,'/b','/a',None,'ask',True,False)), '/a')
check('confirm-original-destination scenario 6', solve('confirm-original-destination', (False,'/b','/a',None,'ask',False,False)), '/a')
check('pending-request-replacement scenario 1', solve('pending-request-replacement', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/b'+str(N))
check('pending-request-replacement scenario 2', solve('pending-request-replacement', (False,'/a','/a','/old','ask',False,True)), None)
check('pending-request-replacement scenario 3', solve('pending-request-replacement', (True,'/b','/a','/b','cancel',False,False)), None)
check('pending-request-replacement scenario 4', solve('pending-request-replacement', (True,'/c','/a','/b','confirm',False,True)), None)
check('pending-request-replacement scenario 5', solve('pending-request-replacement', (True,'/b','/a',None,'ask',True,False)), None)
check('pending-request-replacement scenario 6', solve('pending-request-replacement', (False,'/b','/a',None,'ask',False,False)), None)
check('clear-on-cancel scenario 1', solve('clear-on-cancel', (True,'/b'+str(N),'/a',None,'ask',False,False)), None)
check('clear-on-cancel scenario 2', solve('clear-on-cancel', (False,'/a','/a','/old','ask',False,True)), '/old')
check('clear-on-cancel scenario 3', solve('clear-on-cancel', (True,'/b','/a','/b','cancel',False,False)), None)
check('clear-on-cancel scenario 4', solve('clear-on-cancel', (True,'/c','/a','/b','confirm',False,True)), '/b')
check('clear-on-cancel scenario 5', solve('clear-on-cancel', (True,'/b','/a',None,'ask',True,False)), None)
check('clear-on-cancel scenario 6', solve('clear-on-cancel', (False,'/b','/a',None,'ask',False,False)), None)
check('replace-navigation-mode scenario 1', solve('replace-navigation-mode', (True,'/b'+str(N),'/a',None,'ask',False,False)), 'push')
check('replace-navigation-mode scenario 2', solve('replace-navigation-mode', (False,'/a','/a','/old','ask',False,True)), 'replace')
check('replace-navigation-mode scenario 3', solve('replace-navigation-mode', (True,'/b','/a','/b','cancel',False,False)), 'push')
check('replace-navigation-mode scenario 4', solve('replace-navigation-mode', (True,'/c','/a','/b','confirm',False,True)), 'replace')
check('replace-navigation-mode scenario 5', solve('replace-navigation-mode', (True,'/b','/a',None,'ask',True,False)), 'push')
check('replace-navigation-mode scenario 6', solve('replace-navigation-mode', (False,'/b','/a',None,'ask',False,False)), 'push')
check('same-location-noop scenario 1', solve('same-location-noop', (True,'/b'+str(N),'/a',None,'ask',False,False)), False)
check('same-location-noop scenario 2', solve('same-location-noop', (False,'/a','/a','/old','ask',False,True)), True)
check('same-location-noop scenario 3', solve('same-location-noop', (True,'/b','/a','/b','cancel',False,False)), False)
check('same-location-noop scenario 4', solve('same-location-noop', (True,'/c','/a','/b','confirm',False,True)), False)
check('same-location-noop scenario 5', solve('same-location-noop', (True,'/b','/a',None,'ask',True,False)), False)
check('same-location-noop scenario 6', solve('same-location-noop', (False,'/b','/a',None,'ask',False,False)), False)
check('one-shot-bypass-consumption scenario 1', solve('one-shot-bypass-consumption', (True,'/b'+str(N),'/a',None,'ask',False,False)), False)
check('one-shot-bypass-consumption scenario 2', solve('one-shot-bypass-consumption', (False,'/a','/a','/old','ask',False,True)), False)
check('one-shot-bypass-consumption scenario 3', solve('one-shot-bypass-consumption', (True,'/b','/a','/b','cancel',False,False)), False)
check('one-shot-bypass-consumption scenario 4', solve('one-shot-bypass-consumption', (True,'/c','/a','/b','confirm',False,True)), False)
check('one-shot-bypass-consumption scenario 5', solve('one-shot-bypass-consumption', (True,'/b','/a',None,'ask',True,False)), False)
check('one-shot-bypass-consumption scenario 6', solve('one-shot-bypass-consumption', (False,'/b','/a',None,'ask',False,False)), False)
check('prompt-visibility scenario 1', solve('prompt-visibility', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('prompt-visibility scenario 2', solve('prompt-visibility', (False,'/a','/a','/old','ask',False,True)), False)
check('prompt-visibility scenario 3', solve('prompt-visibility', (True,'/b','/a','/b','cancel',False,False)), False)
check('prompt-visibility scenario 4', solve('prompt-visibility', (True,'/c','/a','/b','confirm',False,True)), False)
check('prompt-visibility scenario 5', solve('prompt-visibility', (True,'/b','/a',None,'ask',True,False)), False)
check('prompt-visibility scenario 6', solve('prompt-visibility', (False,'/b','/a',None,'ask',False,False)), False)
check('discard-only-after-confirm scenario 1', solve('discard-only-after-confirm', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('discard-only-after-confirm scenario 2', solve('discard-only-after-confirm', (False,'/a','/a','/old','ask',False,True)), False)
check('discard-only-after-confirm scenario 3', solve('discard-only-after-confirm', (True,'/b','/a','/b','cancel',False,False)), True)
check('discard-only-after-confirm scenario 4', solve('discard-only-after-confirm', (True,'/c','/a','/b','confirm',False,True)), False)
check('discard-only-after-confirm scenario 5', solve('discard-only-after-confirm', (True,'/b','/a',None,'ask',True,False)), True)
check('discard-only-after-confirm scenario 6', solve('discard-only-after-confirm', (False,'/b','/a',None,'ask',False,False)), 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):
    dirty, target, current, pending, decision, bypass, replace = s
    if operation == 'dirty-transition-gate':
        return dirty and target!=current and not replace
    if operation == 'cancel-retains-location':
        return current if decision=='cancel' else target
    if operation == 'confirm-original-destination':
        return pending if decision=='confirm' and pending is not None else current
    if operation == 'pending-request-replacement':
        return target if decision=='ask' and dirty and not bypass else None
    if operation == 'clear-on-cancel':
        return None if decision=='cancel' else pending
    if operation == 'replace-navigation-mode':
        return 'replace' if replace else 'push'
    if operation == 'same-location-noop':
        return target==current
    if operation == 'one-shot-bypass-consumption':
        return False if bypass and target!=current else bypass
    if operation == 'prompt-visibility':
        return decision=='ask' and dirty and not bypass and target!=current
    if operation == 'discard-only-after-confirm':
        return dirty and decision!='confirm'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-transition-gate scenario 1', solve('dirty-transition-gate', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('dirty-transition-gate scenario 2', solve('dirty-transition-gate', (False,'/a','/a','/old','ask',False,True)), False)
check('dirty-transition-gate scenario 3', solve('dirty-transition-gate', (True,'/b','/a','/b','cancel',False,False)), True)
check('dirty-transition-gate scenario 4', solve('dirty-transition-gate', (True,'/c','/a','/b','confirm',False,True)), True)
check('dirty-transition-gate scenario 5', solve('dirty-transition-gate', (True,'/b','/a',None,'ask',True,False)), False)
check('dirty-transition-gate scenario 6', solve('dirty-transition-gate', (False,'/b','/a',None,'ask',False,False)), False)
check('cancel-retains-location scenario 1', solve('cancel-retains-location', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/b'+str(N))
check('cancel-retains-location scenario 2', solve('cancel-retains-location', (False,'/a','/a','/old','ask',False,True)), '/a')
check('cancel-retains-location scenario 3', solve('cancel-retains-location', (True,'/b','/a','/b','cancel',False,False)), '/a')
check('cancel-retains-location scenario 4', solve('cancel-retains-location', (True,'/c','/a','/b','confirm',False,True)), '/c')
check('cancel-retains-location scenario 5', solve('cancel-retains-location', (True,'/b','/a',None,'ask',True,False)), '/b')
check('cancel-retains-location scenario 6', solve('cancel-retains-location', (False,'/b','/a',None,'ask',False,False)), '/b')
check('confirm-original-destination scenario 1', solve('confirm-original-destination', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/a')
check('confirm-original-destination scenario 2', solve('confirm-original-destination', (False,'/a','/a','/old','ask',False,True)), '/a')
check('confirm-original-destination scenario 3', solve('confirm-original-destination', (True,'/b','/a','/b','cancel',False,False)), '/a')
check('confirm-original-destination scenario 4', solve('confirm-original-destination', (True,'/c','/a','/b','confirm',False,True)), '/b')
check('confirm-original-destination scenario 5', solve('confirm-original-destination', (True,'/b','/a',None,'ask',True,False)), '/a')
check('confirm-original-destination scenario 6', solve('confirm-original-destination', (False,'/b','/a',None,'ask',False,False)), '/a')
check('pending-request-replacement scenario 1', solve('pending-request-replacement', (True,'/b'+str(N),'/a',None,'ask',False,False)), '/b'+str(N))
check('pending-request-replacement scenario 2', solve('pending-request-replacement', (False,'/a','/a','/old','ask',False,True)), None)
check('pending-request-replacement scenario 3', solve('pending-request-replacement', (True,'/b','/a','/b','cancel',False,False)), None)
check('pending-request-replacement scenario 4', solve('pending-request-replacement', (True,'/c','/a','/b','confirm',False,True)), None)
check('pending-request-replacement scenario 5', solve('pending-request-replacement', (True,'/b','/a',None,'ask',True,False)), None)
check('pending-request-replacement scenario 6', solve('pending-request-replacement', (False,'/b','/a',None,'ask',False,False)), None)
check('clear-on-cancel scenario 1', solve('clear-on-cancel', (True,'/b'+str(N),'/a',None,'ask',False,False)), None)
check('clear-on-cancel scenario 2', solve('clear-on-cancel', (False,'/a','/a','/old','ask',False,True)), '/old')
check('clear-on-cancel scenario 3', solve('clear-on-cancel', (True,'/b','/a','/b','cancel',False,False)), None)
check('clear-on-cancel scenario 4', solve('clear-on-cancel', (True,'/c','/a','/b','confirm',False,True)), '/b')
check('clear-on-cancel scenario 5', solve('clear-on-cancel', (True,'/b','/a',None,'ask',True,False)), None)
check('clear-on-cancel scenario 6', solve('clear-on-cancel', (False,'/b','/a',None,'ask',False,False)), None)
check('replace-navigation-mode scenario 1', solve('replace-navigation-mode', (True,'/b'+str(N),'/a',None,'ask',False,False)), 'push')
check('replace-navigation-mode scenario 2', solve('replace-navigation-mode', (False,'/a','/a','/old','ask',False,True)), 'replace')
check('replace-navigation-mode scenario 3', solve('replace-navigation-mode', (True,'/b','/a','/b','cancel',False,False)), 'push')
check('replace-navigation-mode scenario 4', solve('replace-navigation-mode', (True,'/c','/a','/b','confirm',False,True)), 'replace')
check('replace-navigation-mode scenario 5', solve('replace-navigation-mode', (True,'/b','/a',None,'ask',True,False)), 'push')
check('replace-navigation-mode scenario 6', solve('replace-navigation-mode', (False,'/b','/a',None,'ask',False,False)), 'push')
check('same-location-noop scenario 1', solve('same-location-noop', (True,'/b'+str(N),'/a',None,'ask',False,False)), False)
check('same-location-noop scenario 2', solve('same-location-noop', (False,'/a','/a','/old','ask',False,True)), True)
check('same-location-noop scenario 3', solve('same-location-noop', (True,'/b','/a','/b','cancel',False,False)), False)
check('same-location-noop scenario 4', solve('same-location-noop', (True,'/c','/a','/b','confirm',False,True)), False)
check('same-location-noop scenario 5', solve('same-location-noop', (True,'/b','/a',None,'ask',True,False)), False)
check('same-location-noop scenario 6', solve('same-location-noop', (False,'/b','/a',None,'ask',False,False)), False)
check('one-shot-bypass-consumption scenario 1', solve('one-shot-bypass-consumption', (True,'/b'+str(N),'/a',None,'ask',False,False)), False)
check('one-shot-bypass-consumption scenario 2', solve('one-shot-bypass-consumption', (False,'/a','/a','/old','ask',False,True)), False)
check('one-shot-bypass-consumption scenario 3', solve('one-shot-bypass-consumption', (True,'/b','/a','/b','cancel',False,False)), False)
check('one-shot-bypass-consumption scenario 4', solve('one-shot-bypass-consumption', (True,'/c','/a','/b','confirm',False,True)), False)
check('one-shot-bypass-consumption scenario 5', solve('one-shot-bypass-consumption', (True,'/b','/a',None,'ask',True,False)), False)
check('one-shot-bypass-consumption scenario 6', solve('one-shot-bypass-consumption', (False,'/b','/a',None,'ask',False,False)), False)
check('prompt-visibility scenario 1', solve('prompt-visibility', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('prompt-visibility scenario 2', solve('prompt-visibility', (False,'/a','/a','/old','ask',False,True)), False)
check('prompt-visibility scenario 3', solve('prompt-visibility', (True,'/b','/a','/b','cancel',False,False)), False)
check('prompt-visibility scenario 4', solve('prompt-visibility', (True,'/c','/a','/b','confirm',False,True)), False)
check('prompt-visibility scenario 5', solve('prompt-visibility', (True,'/b','/a',None,'ask',True,False)), False)
check('prompt-visibility scenario 6', solve('prompt-visibility', (False,'/b','/a',None,'ask',False,False)), False)
check('discard-only-after-confirm scenario 1', solve('discard-only-after-confirm', (True,'/b'+str(N),'/a',None,'ask',False,False)), True)
check('discard-only-after-confirm scenario 2', solve('discard-only-after-confirm', (False,'/a','/a','/old','ask',False,True)), False)
check('discard-only-after-confirm scenario 3', solve('discard-only-after-confirm', (True,'/b','/a','/b','cancel',False,False)), True)
check('discard-only-after-confirm scenario 4', solve('discard-only-after-confirm', (True,'/c','/a','/b','confirm',False,True)), False)
check('discard-only-after-confirm scenario 5', solve('discard-only-after-confirm', (True,'/b','/a',None,'ask',True,False)), True)
check('discard-only-after-confirm scenario 6', solve('discard-only-after-confirm', (False,'/b','/a',None,'ask',False,False)), 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:
Dirty transition gate.

The blocker asks only for dirty cross-location transitions without a one-shot bypass. Confirmation follows the captured pending destination, cancellation keeps current location and edits, and push versus replace is independent. Operation dirty-transition-gate has the six explicit input/output oracles below.

split: open-access