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

N = 1
observations = []
def solve(operation, s):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return s['pending']
    if operation == 'tombstones':
        return {k:v for k,v in s['server'].items() if k not in s['removed']}
    if operation == 'dirty-pruning':
        return [k for k in s['dirty'] if k in s['client']]
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return [e for e in s['pending'][1:] if e not in s['consumed']]
    if operation == 'tombstones':
        return {k:v for k,v in s['server'].items() if k not in s['removed']}
    if operation == 'dirty-pruning':
        return [k for k in s['dirty'] if k in s['client']]
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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:
Already replayed events execute again.

Server snapshot supplies untouched keys; pre-hydration edits win only for dirty keys. Missing and null differ. Revision, roots, readiness and replay are separate hydration facts. Operation consumed-filter 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):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return [e for e in s['pending'] if e not in s['consumed']]
    if operation == 'tombstones':
        return s['server']
    if operation == 'dirty-pruning':
        return [k for k in s['dirty'] if k in s['client']]
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return [e for e in s['pending'] if e not in s['consumed']]
    if operation == 'tombstones':
        return {k:v for k,v in s['server'].items() if k not in s['dirty']}
    if operation == 'dirty-pruning':
        return [k for k in s['dirty'] if k in s['client']]
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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:
Server-removed keys survive hydration.

Server snapshot supplies untouched keys; pre-hydration edits win only for dirty keys. Missing and null differ. Revision, roots, readiness and replay are separate hydration facts. Operation tombstones 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):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return [e for e in s['pending'] if e not in s['consumed']]
    if operation == 'tombstones':
        return {k:v for k,v in s['server'].items() if k not in s['removed']}
    if operation == 'dirty-pruning':
        return s['dirty']
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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):
    if operation == 'dirty-overlay':
        return {**s['server'], **{k:v for k,v in s['client'].items() if k in s['dirty']}}
    if operation == 'missing-client-key':
        return s['client']['a'] if 'a' in s['client'] else s['server'].get('a')
    if operation == 'snapshot-admission':
        return s['revision'] >= s['client_revision']
    if operation == 'root-binding':
        return s['root'] == s['incoming_root']
    if operation == 'replay-gate':
        return s['pending'] if s['ready'] else []
    if operation == 'consumed-filter':
        return [e for e in s['pending'] if e not in s['consumed']]
    if operation == 'tombstones':
        return {k:v for k,v in s['server'].items() if k not in s['removed']}
    if operation == 'dirty-pruning':
        return [k for k in s['dirty'] if k in s['server']]
    if operation == 'new-client-fields':
        return sorted(set(s['client'])-set(s['server']))
    if operation == 'hydration-status':
        return 'hydrated' if s['ready'] else 'waiting'
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('dirty-overlay scenario 1', solve('dirty-overlay', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':9,'b':2})
check('dirty-overlay scenario 2', solve('dirty-overlay', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('dirty-overlay scenario 3', solve('dirty-overlay', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {'a':N})
check('dirty-overlay scenario 4', solve('dirty-overlay', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'a':None,'b':N})
check('dirty-overlay scenario 5', solve('dirty-overlay', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('dirty-overlay scenario 6', solve('dirty-overlay', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('missing-client-key scenario 1', solve('missing-client-key', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 9)
check('missing-client-key scenario 2', solve('missing-client-key', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 0)
check('missing-client-key scenario 3', solve('missing-client-key', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), N)
check('missing-client-key scenario 4', solve('missing-client-key', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), None)
check('missing-client-key scenario 5', solve('missing-client-key', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), N)
check('missing-client-key scenario 6', solve('missing-client-key', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('snapshot-admission scenario 1', solve('snapshot-admission', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('snapshot-admission scenario 2', solve('snapshot-admission', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('snapshot-admission scenario 3', solve('snapshot-admission', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('snapshot-admission scenario 4', solve('snapshot-admission', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), True)
check('snapshot-admission scenario 5', solve('snapshot-admission', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('snapshot-admission scenario 6', solve('snapshot-admission', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), False)
check('root-binding scenario 1', solve('root-binding', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), True)
check('root-binding scenario 2', solve('root-binding', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), False)
check('root-binding scenario 3', solve('root-binding', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), True)
check('root-binding scenario 4', solve('root-binding', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), False)
check('root-binding scenario 5', solve('root-binding', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), True)
check('root-binding scenario 6', solve('root-binding', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), True)
check('replay-gate scenario 1', solve('replay-gate', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e1','e2'])
check('replay-gate scenario 2', solve('replay-gate', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('replay-gate scenario 3', solve('replay-gate', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('replay-gate scenario 4', solve('replay-gate', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['e2'])
check('replay-gate scenario 5', solve('replay-gate', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('replay-gate scenario 6', solve('replay-gate', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('consumed-filter scenario 1', solve('consumed-filter', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['e2'])
check('consumed-filter scenario 2', solve('consumed-filter', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['e1'])
check('consumed-filter scenario 3', solve('consumed-filter', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), [])
check('consumed-filter scenario 4', solve('consumed-filter', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('consumed-filter scenario 5', solve('consumed-filter', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), ['e3'])
check('consumed-filter scenario 6', solve('consumed-filter', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), ['e4'])
check('tombstones scenario 1', solve('tombstones', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), {'a':N})
check('tombstones scenario 2', solve('tombstones', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), {'a':None})
check('tombstones scenario 3', solve('tombstones', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), {})
check('tombstones scenario 4', solve('tombstones', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), {'b':N})
check('tombstones scenario 5', solve('tombstones', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), {'a':N})
check('tombstones scenario 6', solve('tombstones', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), {'a':False})
check('dirty-pruning scenario 1', solve('dirty-pruning', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), ['a'])
check('dirty-pruning scenario 2', solve('dirty-pruning', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), [])
check('dirty-pruning scenario 3', solve('dirty-pruning', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('dirty-pruning scenario 4', solve('dirty-pruning', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), ['a'])
check('dirty-pruning scenario 5', solve('dirty-pruning', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('dirty-pruning scenario 6', solve('dirty-pruning', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('new-client-fields scenario 1', solve('new-client-fields', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), [])
check('new-client-fields scenario 2', solve('new-client-fields', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), ['c'])
check('new-client-fields scenario 3', solve('new-client-fields', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), ['a'])
check('new-client-fields scenario 4', solve('new-client-fields', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), [])
check('new-client-fields scenario 5', solve('new-client-fields', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), [])
check('new-client-fields scenario 6', solve('new-client-fields', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), [])
check('hydration-status scenario 1', solve('hydration-status', dict(server={'a':N,'b':2}, client={'a':9,'b':3}, dirty=['a'], revision=2, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e1','e2'], consumed=['e1'], removed=['b'])), 'hydrated')
check('hydration-status scenario 2', solve('hydration-status', dict(server={'a':None}, client={'a':0,'c':N}, dirty=[], revision=1, client_revision=2, root='r', incoming_root='x', ready=False, pending=['e1'], consumed=[], removed=[])), 'waiting')
check('hydration-status scenario 3', solve('hydration-status', dict(server={}, client={'a':N}, dirty=['a'], revision=0, client_revision=0, root='x', incoming_root='x', ready=True, pending=[], consumed=[], removed=[])), 'hydrated')
check('hydration-status scenario 4', solve('hydration-status', dict(server={'a':0,'b':N}, client={'a':None}, dirty=['a'], revision=3, client_revision=3, root='x', incoming_root='r', ready=True, pending=['e2'], consumed=['e2'], removed=['a'])), 'hydrated')
check('hydration-status scenario 5', solve('hydration-status', dict(server={'a':N}, client={}, dirty=[], revision=1, client_revision=0, root='r', incoming_root='r', ready=False, pending=['e3','e1'], consumed=['e1'], removed=['z'])), 'waiting')
check('hydration-status scenario 6', solve('hydration-status', dict(server={'a':False}, client={'a':True}, dirty=['z'], revision=0, client_revision=1, root='r', incoming_root='r', ready=True, pending=['e4'], consumed=['e9'], removed=[])), 'hydrated')
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:
Absent dirty keys retain hydration ownership.

Server snapshot supplies untouched keys; pre-hydration edits win only for dirty keys. Missing and null differ. Revision, roots, readiness and replay are separate hydration facts. Operation dirty-pruning has the six explicit input/output oracles below.

split: open-access