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

N = 1
observations = []
def solve(operation, s):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return sent+1 if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Next save revision.

Autosave snapshots both revision and field set. A successful old save acknowledges its sent revision without clearing newer edits. Offline and composition defer new saves, and conflicts preserve local edits for explicit resolution. Operation next-save-revision 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):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return dirty_fields
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in sent_fields if f not in dirty_fields]
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unsent field difference.

Autosave snapshots both revision and field set. A successful old save acknowledges its sent revision without clearing newer edits. Offline and composition defer new saves, and conflicts preserve local edits for explicit resolution. Operation unsent-field-difference 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):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return sent_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return max(0,current-acknowledged)
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Conflict preserves local fields.

Autosave snapshots both revision and field set. A successful old save acknowledges its sent revision without clearing newer edits. Offline and composition defer new saves, and conflicts preserve local edits for explicit resolution. Operation conflict-preserves-local-fields 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):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return current-sent
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(operation, s):
    current, sent, acknowledged, dirty_fields, sent_fields, response, online, composing = s
    if operation == 'acknowledge-sent-revision':
        return sent if response=='ok' else acknowledged
    if operation == 'newer-edit-retains-dirty':
        return dirty_fields if current!=sent or response!='ok' else [f for f in dirty_fields if f not in sent_fields]
    if operation == 'composition-defers-save':
        return online and bool(dirty_fields) and not composing
    if operation == 'save-completion-status':
        return 'conflict' if response=='conflict' else ('error' if response=='failed' else ('saved' if current==sent else 'unsaved'))
    if operation == 'next-save-revision':
        return current if current>sent else None
    if operation == 'unsent-field-difference':
        return [f for f in dirty_fields if f not in sent_fields]
    if operation == 'conflict-preserves-local-fields':
        return dirty_fields if response=='conflict' else []
    if operation == 'save-payload-field-snapshot':
        return list(sent_fields)
    if operation == 'unacknowledged-edit-distance':
        return sent-acknowledged
    if operation == 'resave-after-ack':
        return response=='ok' and current>sent and online and not composing
    raise ValueError('unknown modeled operation')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('acknowledge-sent-revision scenario 1', solve('acknowledge-sent-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+1)
check('acknowledge-sent-revision scenario 2', solve('acknowledge-sent-revision', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('acknowledge-sent-revision scenario 3', solve('acknowledge-sent-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 0)
check('acknowledge-sent-revision scenario 4', solve('acknowledge-sent-revision', (0,0,0,[],[],'ok',True,True)), 0)
check('acknowledge-sent-revision scenario 5', solve('acknowledge-sent-revision', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('acknowledge-sent-revision scenario 6', solve('acknowledge-sent-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 3)
check('newer-edit-retains-dirty scenario 1', solve('newer-edit-retains-dirty', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 2', solve('newer-edit-retains-dirty', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('newer-edit-retains-dirty scenario 3', solve('newer-edit-retains-dirty', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a','b'])
check('newer-edit-retains-dirty scenario 4', solve('newer-edit-retains-dirty', (0,0,0,[],[],'ok',True,True)), [])
check('newer-edit-retains-dirty scenario 5', solve('newer-edit-retains-dirty', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('newer-edit-retains-dirty scenario 6', solve('newer-edit-retains-dirty', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('composition-defers-save scenario 1', solve('composition-defers-save', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 2', solve('composition-defers-save', (1,1,0,['a'],['a'],'ok',True,False)), True)
check('composition-defers-save scenario 3', solve('composition-defers-save', (2,1,0,['a','b'],['a'],'failed',True,False)), True)
check('composition-defers-save scenario 4', solve('composition-defers-save', (0,0,0,[],[],'ok',True,True)), False)
check('composition-defers-save scenario 5', solve('composition-defers-save', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('composition-defers-save scenario 6', solve('composition-defers-save', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('save-completion-status scenario 1', solve('save-completion-status', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 'unsaved')
check('save-completion-status scenario 2', solve('save-completion-status', (1,1,0,['a'],['a'],'ok',True,False)), 'saved')
check('save-completion-status scenario 3', solve('save-completion-status', (2,1,0,['a','b'],['a'],'failed',True,False)), 'error')
check('save-completion-status scenario 4', solve('save-completion-status', (0,0,0,[],[],'ok',True,True)), 'saved')
check('save-completion-status scenario 5', solve('save-completion-status', (3,2,1,['b'],['a'],'ok',False,False)), 'unsaved')
check('save-completion-status scenario 6', solve('save-completion-status', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 'conflict')
check('next-save-revision scenario 1', solve('next-save-revision', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), N+2)
check('next-save-revision scenario 2', solve('next-save-revision', (1,1,0,['a'],['a'],'ok',True,False)), None)
check('next-save-revision scenario 3', solve('next-save-revision', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('next-save-revision scenario 4', solve('next-save-revision', (0,0,0,[],[],'ok',True,True)), None)
check('next-save-revision scenario 5', solve('next-save-revision', (3,2,1,['b'],['a'],'ok',False,False)), 3)
check('next-save-revision scenario 6', solve('next-save-revision', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), None)
check('unsent-field-difference scenario 1', solve('unsent-field-difference', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['b'])
check('unsent-field-difference scenario 2', solve('unsent-field-difference', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('unsent-field-difference scenario 3', solve('unsent-field-difference', (2,1,0,['a','b'],['a'],'failed',True,False)), ['b'])
check('unsent-field-difference scenario 4', solve('unsent-field-difference', (0,0,0,[],[],'ok',True,True)), [])
check('unsent-field-difference scenario 5', solve('unsent-field-difference', (3,2,1,['b'],['a'],'ok',False,False)), ['b'])
check('unsent-field-difference scenario 6', solve('unsent-field-difference', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), [])
check('conflict-preserves-local-fields scenario 1', solve('conflict-preserves-local-fields', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 2', solve('conflict-preserves-local-fields', (1,1,0,['a'],['a'],'ok',True,False)), [])
check('conflict-preserves-local-fields scenario 3', solve('conflict-preserves-local-fields', (2,1,0,['a','b'],['a'],'failed',True,False)), [])
check('conflict-preserves-local-fields scenario 4', solve('conflict-preserves-local-fields', (0,0,0,[],[],'ok',True,True)), [])
check('conflict-preserves-local-fields scenario 5', solve('conflict-preserves-local-fields', (3,2,1,['b'],['a'],'ok',False,False)), [])
check('conflict-preserves-local-fields scenario 6', solve('conflict-preserves-local-fields', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('save-payload-field-snapshot scenario 1', solve('save-payload-field-snapshot', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 2', solve('save-payload-field-snapshot', (1,1,0,['a'],['a'],'ok',True,False)), ['a'])
check('save-payload-field-snapshot scenario 3', solve('save-payload-field-snapshot', (2,1,0,['a','b'],['a'],'failed',True,False)), ['a'])
check('save-payload-field-snapshot scenario 4', solve('save-payload-field-snapshot', (0,0,0,[],[],'ok',True,True)), [])
check('save-payload-field-snapshot scenario 5', solve('save-payload-field-snapshot', (3,2,1,['b'],['a'],'ok',False,False)), ['a'])
check('save-payload-field-snapshot scenario 6', solve('save-payload-field-snapshot', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), ['a','b'])
check('unacknowledged-edit-distance scenario 1', solve('unacknowledged-edit-distance', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), 2)
check('unacknowledged-edit-distance scenario 2', solve('unacknowledged-edit-distance', (1,1,0,['a'],['a'],'ok',True,False)), 1)
check('unacknowledged-edit-distance scenario 3', solve('unacknowledged-edit-distance', (2,1,0,['a','b'],['a'],'failed',True,False)), 2)
check('unacknowledged-edit-distance scenario 4', solve('unacknowledged-edit-distance', (0,0,0,[],[],'ok',True,True)), 0)
check('unacknowledged-edit-distance scenario 5', solve('unacknowledged-edit-distance', (3,2,1,['b'],['a'],'ok',False,False)), 2)
check('unacknowledged-edit-distance scenario 6', solve('unacknowledged-edit-distance', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), 1)
check('resave-after-ack scenario 1', solve('resave-after-ack', (N+2,N+1,N,['a','b'],['a'],'ok',True,False)), True)
check('resave-after-ack scenario 2', solve('resave-after-ack', (1,1,0,['a'],['a'],'ok',True,False)), False)
check('resave-after-ack scenario 3', solve('resave-after-ack', (2,1,0,['a','b'],['a'],'failed',True,False)), False)
check('resave-after-ack scenario 4', solve('resave-after-ack', (0,0,0,[],[],'ok',True,True)), False)
check('resave-after-ack scenario 5', solve('resave-after-ack', (3,2,1,['b'],['a'],'ok',False,False)), False)
check('resave-after-ack scenario 6', solve('resave-after-ack', (4,4,3,['a','b'],['a','b'],'conflict',True,True)), False)
check('many edits during conflicting save: acknowledge-sent-revision', solve('acknowledge-sent-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 1)
check('many edits during conflicting save: newer-edit-retains-dirty', solve('newer-edit-retains-dirty', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: composition-defers-save', solve('composition-defers-save', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), True)
check('many edits during conflicting save: save-completion-status', solve('save-completion-status', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), 'conflict')
check('many edits during conflicting save: next-save-revision', solve('next-save-revision', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+5)
check('many edits during conflicting save: unsent-field-difference', solve('unsent-field-difference', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['b'])
check('many edits during conflicting save: conflict-preserves-local-fields', solve('conflict-preserves-local-fields', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a','b'])
check('many edits during conflicting save: save-payload-field-snapshot', solve('save-payload-field-snapshot', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), ['a'])
check('many edits during conflicting save: unacknowledged-edit-distance', solve('unacknowledged-edit-distance', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), N+4)
check('many edits during conflicting save: resave-after-ack', solve('resave-after-ack', (N+5,2,1,['a','b'],['a'],'conflict',True,False)), False)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unacknowledged edit distance.

Autosave snapshots both revision and field set. A successful old save acknowledges its sent revision without clearing newer edits. Offline and composition defer new saves, and conflicts preserve local edits for explicit resolution. Operation unacknowledged-edit-distance has the six explicit input/output oracles below.

split: open-access