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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return patches
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Pending retention.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation pending-retention 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):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return next((v for k,v in patches if k in rejected),0)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Rollback delta.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation rollback-delta 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):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return sorted((k for k,v in patches), reverse=True)
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches][::-1]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Journal order.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation journal-order 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):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches if v>0)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Visible total.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation visible-total 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):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if v and k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Acknowledged identities.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation acknowledged-identities 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):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return rejected
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    base, patches, rejected, confirmed = s
    if operation == 'rejected-rebase':
        return base+sum(v for k,v in patches if k not in rejected)
    if operation == 'confirmed-base':
        return base+sum(v for k,v in patches if k in confirmed)
    if operation == 'pending-retention':
        return [(k,v) for k,v in patches if k not in confirmed and k not in rejected]
    if operation == 'rollback-delta':
        return sum(v for k,v in patches if k in rejected)
    if operation == 'journal-order':
        return [k for k,v in patches]
    if operation == 'visible-total':
        return base+sum(v for k,v in patches)
    if operation == 'acknowledged-identities':
        return [k for k,v in patches if k in confirmed]
    if operation == 'failure-identities':
        return [k for k,v in patches if k in rejected][:1]
    if operation == 'pending-flag':
        return any(k not in confirmed and k not in rejected for k,v in patches)
    if operation == 'next-compensating-actions':
        return [(k,-v) for k,v in reversed(patches) if k in rejected]
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('rejected-rebase scenario 1', solve('rejected-rebase', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('rejected-rebase scenario 2', solve('rejected-rebase', (0, [('p',N)], [], [])), N)
check('rejected-rebase scenario 3', solve('rejected-rebase', (N, [], [], [])), N)
check('rejected-rebase scenario 4', solve('rejected-rebase', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 3)
check('rejected-rebase scenario 5', solve('rejected-rebase', (N, [('p',0)], ['x'], ['p'])), N)
check('rejected-rebase scenario 6', solve('rejected-rebase', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('confirmed-base scenario 1', solve('confirmed-base', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N-1)
check('confirmed-base scenario 2', solve('confirmed-base', (0, [('p',N)], [], [])), 0)
check('confirmed-base scenario 3', solve('confirmed-base', (N, [], [], [])), N)
check('confirmed-base scenario 4', solve('confirmed-base', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 2)
check('confirmed-base scenario 5', solve('confirmed-base', (N, [('p',0)], ['x'], ['p'])), N)
check('confirmed-base scenario 6', solve('confirmed-base', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('pending-retention scenario 1', solve('pending-retention', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [])
check('pending-retention scenario 2', solve('pending-retention', (0, [('p',N)], [], [])), [('p',N)])
check('pending-retention scenario 3', solve('pending-retention', (N, [], [], [])), [])
check('pending-retention scenario 4', solve('pending-retention', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('r',1)])
check('pending-retention scenario 5', solve('pending-retention', (N, [('p',0)], ['x'], ['p'])), [])
check('pending-retention scenario 6', solve('pending-retention', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('rollback-delta scenario 1', solve('rollback-delta', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 2)
check('rollback-delta scenario 2', solve('rollback-delta', (0, [('p',N)], [], [])), 0)
check('rollback-delta scenario 3', solve('rollback-delta', (N, [], [], [])), 0)
check('rollback-delta scenario 4', solve('rollback-delta', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 4)
check('rollback-delta scenario 5', solve('rollback-delta', (N, [('p',0)], ['x'], ['p'])), 0)
check('rollback-delta scenario 6', solve('rollback-delta', (2, [('p',1),('q',1)], ['p','q'], [])), 2)
check('journal-order scenario 1', solve('journal-order', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p','q'])
check('journal-order scenario 2', solve('journal-order', (0, [('p',N)], [], [])), ['p'])
check('journal-order scenario 3', solve('journal-order', (N, [], [], [])), [])
check('journal-order scenario 4', solve('journal-order', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p','q','r'])
check('journal-order scenario 5', solve('journal-order', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('journal-order scenario 6', solve('journal-order', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('visible-total scenario 1', solve('visible-total', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), 10*N+1)
check('visible-total scenario 2', solve('visible-total', (0, [('p',N)], [], [])), N)
check('visible-total scenario 3', solve('visible-total', (N, [], [], [])), N)
check('visible-total scenario 4', solve('visible-total', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), 7)
check('visible-total scenario 5', solve('visible-total', (N, [('p',0)], ['x'], ['p'])), N)
check('visible-total scenario 6', solve('visible-total', (2, [('p',1),('q',1)], ['p','q'], [])), 4)
check('acknowledged-identities scenario 1', solve('acknowledged-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['q'])
check('acknowledged-identities scenario 2', solve('acknowledged-identities', (0, [('p',N)], [], [])), [])
check('acknowledged-identities scenario 3', solve('acknowledged-identities', (N, [], [], [])), [])
check('acknowledged-identities scenario 4', solve('acknowledged-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['p'])
check('acknowledged-identities scenario 5', solve('acknowledged-identities', (N, [('p',0)], ['x'], ['p'])), ['p'])
check('acknowledged-identities scenario 6', solve('acknowledged-identities', (2, [('p',1),('q',1)], ['p','q'], [])), [])
check('failure-identities scenario 1', solve('failure-identities', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), ['p'])
check('failure-identities scenario 2', solve('failure-identities', (0, [('p',N)], [], [])), [])
check('failure-identities scenario 3', solve('failure-identities', (N, [], [], [])), [])
check('failure-identities scenario 4', solve('failure-identities', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), ['q'])
check('failure-identities scenario 5', solve('failure-identities', (N, [('p',0)], ['x'], ['p'])), [])
check('failure-identities scenario 6', solve('failure-identities', (2, [('p',1),('q',1)], ['p','q'], [])), ['p','q'])
check('pending-flag scenario 1', solve('pending-flag', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), False)
check('pending-flag scenario 2', solve('pending-flag', (0, [('p',N)], [], [])), True)
check('pending-flag scenario 3', solve('pending-flag', (N, [], [], [])), False)
check('pending-flag scenario 4', solve('pending-flag', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), True)
check('pending-flag scenario 5', solve('pending-flag', (N, [('p',0)], ['x'], ['p'])), False)
check('pending-flag scenario 6', solve('pending-flag', (2, [('p',1),('q',1)], ['p','q'], [])), False)
check('next-compensating-actions scenario 1', solve('next-compensating-actions', (10*N, [('p',2),('q',-1)], ['p'], ['q'])), [('p',-2)])
check('next-compensating-actions scenario 2', solve('next-compensating-actions', (0, [('p',N)], [], [])), [])
check('next-compensating-actions scenario 3', solve('next-compensating-actions', (N, [], [], [])), [])
check('next-compensating-actions scenario 4', solve('next-compensating-actions', (5, [('p',-3),('q',4),('r',1)], ['q'], ['p'])), [('q',-4)])
check('next-compensating-actions scenario 5', solve('next-compensating-actions', (N, [('p',0)], ['x'], ['p'])), [])
check('next-compensating-actions scenario 6', solve('next-compensating-actions', (2, [('p',1),('q',1)], ['p','q'], [])), [('q',-1),('p',-1)])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Failure identities.

A client numeric patch journal retains insertion order. Accepted patches move to the base; rejected patches are removed and compensate in reverse order; pending patches remain visible. Identity and zero-valued patches are significant. Operation failure-identities has the six explicit input/output oracles below.

split: open-access