FA-19731 / Protocols / Open access
Delimited batch command controller: sealed / validation failed · case 01
While sealed, event validation_failed produces committed/apply instead of idle/reject_discard.
ROOT CAUSE
In sealed, the validation failed handler runs apply and enters committed; it must instead run reject discard and enter idle.
VERIFIED REPAIR
In phase sealed, classify validation_failed as transition to idle and emit reject_discard.
Unsuccessful approach: The partial repair chooses idle/keep_batch, which still violates this phase-specific event contract.
Case contract
For the stipulated Delimited batch command controller, initialize the explicitly shown resource registers from seed (1..5), then consume classified events sequentially. After each event return a deep snapshot of phase, resource registers, and cumulative emitted control frames. The explicit ten phase/event rules and their resource effects define admission and response semantics. Unlisted events preserve phase and emit rejection. Payload is the consecutive integers seed through 2*seed+1. Empty event input returns no observations.
Why this case matters
Incorrect event admission now changes concrete queued data, resource ownership, or emitted protocol frames and subsequent trace behavior.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(phase, events, seed):
payload = list(range(seed, seed * 2 + 2))
r = {'staged': payload[:] if phase in ('collecting','sealed') else [], 'application': [seed-1], 'sealed': phase in ('sealed','committed'), 'receipt': seed if phase=='committed' else None, 'valid': True}
frames = []
observed = []
table = {('idle', 'begin'): ('collecting', 'create_batch'), ('collecting', 'operation'): ('collecting', 'stage_operation'), ('collecting', 'seal'): ('sealed', 'freeze_batch'), ('sealed', 'commit'): ('committed', 'apply_once'), ('collecting', 'commit'): ('collecting', 'reject_unsealed'), ('sealed', 'operation'): ('sealed', 'reject_sealed'), ('collecting', 'abort'): ('idle', 'discard_batch'), ('committed', 'duplicate_commit'): ('committed', 'repeat_receipt'), ('sealed', 'validation_failed'): ('committed', 'apply'), ('committed', 'receipt_consumed'): ('idle', 'release_receipt')}
for event in events:
phase, action = table.get((phase, event), (phase, "reject"))
if action == 'create_batch':
r['staged']=[]; r['sealed']=False
elif action == 'stage_operation':
r['staged'].extend(payload)
elif action == 'freeze_batch':
r['sealed']=True
elif action == 'apply_once':
r['application'].extend(r['staged']); r['staged']=[]
elif action == 'reject_unsealed':
frames.append(['UNSEALED',seed])
elif action == 'reject_sealed':
frames.append(['SEALED',seed])
elif action == 'discard_batch':
r['staged']=[]
elif action == 'repeat_receipt':
frames.append(['COMMITTED',r['receipt']])
elif action == 'reject_discard':
r['staged']=[]; frames.append(['INVALID',seed])
elif action == 'release_receipt':
r['receipt']=None
elif action == 'apply':
r['application'].extend(r['staged'])
elif action == 'apply_operation':
r['application'].extend(payload)
elif action == 'replace_operations':
r['staged']=payload[:]
elif action == 'allow_append':
r['sealed']=False
elif action == 'apply_reversed':
r['application'].extend(reversed(r['staged'])); r['staged']=[]
elif action == 'discard':
r['staged']=[]
elif action == 'discard_receipt':
r['receipt']=None
elif action == 'clear_application':
r['application']=[]
else:
if action not in ("wait", "ignore", "keep", "retain", "keep_peer", "keep_offer", "keep_hold", "keep_batch", "retain_staging", "keep_staging", "keep_local_owner", "keep_old_session", "keep_address", "keep_old_expiry", "ignore_conflict", "keep_service", "keep_subscription", "retain_shadow", "keep_live", "keep_suspicion", "keep_roles", "keep_staged"):
frames.append([action, payload[:]])
observed.append(json.loads(json.dumps({"phase": phase, "registers": r, "frames": frames})))
return observed
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3, 1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 1]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 1]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': 1, 'valid': True}, 'frames': [['COMMITTED', 1]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5, 2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 2]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 2]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': 2, 'valid': True}, 'frames': [['COMMITTED', 2]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 3]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 3]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': 3, 'valid': True}, 'frames': [['COMMITTED', 3]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 4]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 4]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': 4, 'valid': True}, 'frames': [['COMMITTED', 4]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 5]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 5]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': 5, 'valid': True}, 'frames': [['COMMITTED', 5]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit', 'receipt_consumed'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal', 'operation'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None], ['SEALED', 5]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [5, 6, 7, 8, 9, 10, 11]]]}])]}
for label, phase, events, expected in cases[N]:
check(label, solve(phase, events, N), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| idle/begin | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| collecting/operation | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | Passed |
| collecting/seal | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/commit | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| collecting/commit | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/operation | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| collecting/abort | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| committed/duplicate_commit | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| sealed/validation_failed | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Failed |
| committed/receipt_consumed | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| ordered trace 0 | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'committed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['reject', [1, 2, 3]]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Failed |
| ordered trace 3 | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| empty input | [] | [] | Passed |
| unknown event | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
SHA-256 / 7a44dfe02253b7e0a05deec819882fee3d1233537e3562f0edf58a7e96438cf4
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(phase, events, seed):
payload = list(range(seed, seed * 2 + 2))
r = {'staged': payload[:] if phase in ('collecting','sealed') else [], 'application': [seed-1], 'sealed': phase in ('sealed','committed'), 'receipt': seed if phase=='committed' else None, 'valid': True}
frames = []
observed = []
table = {('idle', 'begin'): ('collecting', 'create_batch'), ('collecting', 'operation'): ('collecting', 'stage_operation'), ('collecting', 'seal'): ('sealed', 'freeze_batch'), ('sealed', 'commit'): ('committed', 'apply_once'), ('collecting', 'commit'): ('collecting', 'reject_unsealed'), ('sealed', 'operation'): ('sealed', 'reject_sealed'), ('collecting', 'abort'): ('idle', 'discard_batch'), ('committed', 'duplicate_commit'): ('committed', 'repeat_receipt'), ('sealed', 'validation_failed'): ('idle', 'keep_batch'), ('committed', 'receipt_consumed'): ('idle', 'release_receipt')}
for event in events:
phase, action = table.get((phase, event), (phase, "reject"))
if action == 'create_batch':
r['staged']=[]; r['sealed']=False
elif action == 'stage_operation':
r['staged'].extend(payload)
elif action == 'freeze_batch':
r['sealed']=True
elif action == 'apply_once':
r['application'].extend(r['staged']); r['staged']=[]
elif action == 'reject_unsealed':
frames.append(['UNSEALED',seed])
elif action == 'reject_sealed':
frames.append(['SEALED',seed])
elif action == 'discard_batch':
r['staged']=[]
elif action == 'repeat_receipt':
frames.append(['COMMITTED',r['receipt']])
elif action == 'reject_discard':
r['staged']=[]; frames.append(['INVALID',seed])
elif action == 'release_receipt':
r['receipt']=None
elif action == 'apply':
r['application'].extend(r['staged'])
elif action == 'apply_operation':
r['application'].extend(payload)
elif action == 'replace_operations':
r['staged']=payload[:]
elif action == 'allow_append':
r['sealed']=False
elif action == 'apply_reversed':
r['application'].extend(reversed(r['staged'])); r['staged']=[]
elif action == 'discard':
r['staged']=[]
elif action == 'discard_receipt':
r['receipt']=None
elif action == 'clear_application':
r['application']=[]
else:
if action not in ("wait", "ignore", "keep", "retain", "keep_peer", "keep_offer", "keep_hold", "keep_batch", "retain_staging", "keep_staging", "keep_local_owner", "keep_old_session", "keep_address", "keep_old_expiry", "ignore_conflict", "keep_service", "keep_subscription", "retain_shadow", "keep_live", "keep_suspicion", "keep_roles", "keep_staged"):
frames.append([action, payload[:]])
observed.append(json.loads(json.dumps({"phase": phase, "registers": r, "frames": frames})))
return observed
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3, 1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 1]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 1]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': 1, 'valid': True}, 'frames': [['COMMITTED', 1]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5, 2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 2]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 2]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': 2, 'valid': True}, 'frames': [['COMMITTED', 2]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 3]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 3]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': 3, 'valid': True}, 'frames': [['COMMITTED', 3]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 4]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 4]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': 4, 'valid': True}, 'frames': [['COMMITTED', 4]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 5]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 5]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': 5, 'valid': True}, 'frames': [['COMMITTED', 5]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit', 'receipt_consumed'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal', 'operation'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None], ['SEALED', 5]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [5, 6, 7, 8, 9, 10, 11]]]}])]}
for label, phase, events, expected in cases[N]:
check(label, solve(phase, events, N), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| idle/begin | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| collecting/operation | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | Passed |
| collecting/seal | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/commit | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| collecting/commit | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/operation | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| collecting/abort | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| committed/duplicate_commit | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| sealed/validation_failed | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Failed |
| committed/receipt_consumed | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| ordered trace 0 | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Failed |
| ordered trace 3 | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| empty input | [] | [] | Passed |
| unknown event | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
SHA-256 / 193867a06326f81f4adf85b3b8fa08d1897403a8ac0c119068be58cdd98d5cf3
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(phase, events, seed):
payload = list(range(seed, seed * 2 + 2))
r = {'staged': payload[:] if phase in ('collecting','sealed') else [], 'application': [seed-1], 'sealed': phase in ('sealed','committed'), 'receipt': seed if phase=='committed' else None, 'valid': True}
frames = []
observed = []
table = {('idle', 'begin'): ('collecting', 'create_batch'), ('collecting', 'operation'): ('collecting', 'stage_operation'), ('collecting', 'seal'): ('sealed', 'freeze_batch'), ('sealed', 'commit'): ('committed', 'apply_once'), ('collecting', 'commit'): ('collecting', 'reject_unsealed'), ('sealed', 'operation'): ('sealed', 'reject_sealed'), ('collecting', 'abort'): ('idle', 'discard_batch'), ('committed', 'duplicate_commit'): ('committed', 'repeat_receipt'), ('sealed', 'validation_failed'): ('idle', 'reject_discard'), ('committed', 'receipt_consumed'): ('idle', 'release_receipt')}
for event in events:
phase, action = table.get((phase, event), (phase, "reject"))
if action == 'create_batch':
r['staged']=[]; r['sealed']=False
elif action == 'stage_operation':
r['staged'].extend(payload)
elif action == 'freeze_batch':
r['sealed']=True
elif action == 'apply_once':
r['application'].extend(r['staged']); r['staged']=[]
elif action == 'reject_unsealed':
frames.append(['UNSEALED',seed])
elif action == 'reject_sealed':
frames.append(['SEALED',seed])
elif action == 'discard_batch':
r['staged']=[]
elif action == 'repeat_receipt':
frames.append(['COMMITTED',r['receipt']])
elif action == 'reject_discard':
r['staged']=[]; frames.append(['INVALID',seed])
elif action == 'release_receipt':
r['receipt']=None
elif action == 'apply':
r['application'].extend(r['staged'])
elif action == 'apply_operation':
r['application'].extend(payload)
elif action == 'replace_operations':
r['staged']=payload[:]
elif action == 'allow_append':
r['sealed']=False
elif action == 'apply_reversed':
r['application'].extend(reversed(r['staged'])); r['staged']=[]
elif action == 'discard':
r['staged']=[]
elif action == 'discard_receipt':
r['receipt']=None
elif action == 'clear_application':
r['application']=[]
else:
if action not in ("wait", "ignore", "keep", "retain", "keep_peer", "keep_offer", "keep_hold", "keep_batch", "retain_staging", "keep_staging", "keep_local_owner", "keep_old_session", "keep_address", "keep_old_expiry", "ignore_conflict", "keep_service", "keep_subscription", "retain_shadow", "keep_live", "keep_suspicion", "keep_roles", "keep_staged"):
frames.append([action, payload[:]])
observed.append(json.loads(json.dumps({"phase": phase, "registers": r, "frames": frames})))
return observed
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3, 1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 1]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [1, 2, 3], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 1]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': 1, 'valid': True}, 'frames': [['COMMITTED', 1]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 1]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [0, 1, 2, 3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [0], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [1, 2, 3]]]}])], 2: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5, 2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 2]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 2]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': 2, 'valid': True}, 'frames': [['COMMITTED', 2]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}, {'phase': 'collecting', 'registers': {'staged': [2, 3, 4, 5], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 2]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [1, 2, 3, 4, 5], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [1], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [2, 3, 4, 5]]]}])], 3: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7, 3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 3]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 3]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': 3, 'valid': True}, 'frames': [['COMMITTED', 3]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'collecting', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}, {'phase': 'sealed', 'registers': {'staged': [3, 4, 5, 6, 7], 'application': [2], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 3]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [2, 3, 4, 5, 6, 7], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [2], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [3, 4, 5, 6, 7]]]}])], 4: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9, 4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 4]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 4]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': 4, 'valid': True}, 'frames': [['COMMITTED', 4]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'collecting', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'sealed', 'registers': {'staged': [4, 5, 6, 7, 8, 9], 'application': [3], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 4]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [3, 4, 5, 6, 7, 8, 9], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [3], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [4, 5, 6, 7, 8, 9]]]}])], 5: [('idle/begin', 'idle', ['begin'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/operation', 'collecting', ['operation'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/seal', 'collecting', ['seal'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('sealed/commit', 'sealed', ['commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('collecting/commit', 'collecting', ['commit'], [{'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['UNSEALED', 5]]}]), ('sealed/operation', 'sealed', ['operation'], [{'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['SEALED', 5]]}]), ('collecting/abort', 'collecting', ['abort'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}]), ('committed/duplicate_commit', 'committed', ['duplicate_commit'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': 5, 'valid': True}, 'frames': [['COMMITTED', 5]]}]), ('sealed/validation_failed', 'sealed', ['validation_failed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('committed/receipt_consumed', 'committed', ['receipt_consumed'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}]), ('ordered trace 0', 'idle', ['begin', 'seal', 'validation_failed', 'begin', 'operation', 'seal', 'commit', 'receipt_consumed'], [{'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'collecting', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'sealed', 'registers': {'staged': [5, 6, 7, 8, 9, 10, 11], 'application': [4], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['INVALID', 5]]}]), ('ordered trace 3', 'sealed', ['commit', 'duplicate_commit', 'receipt_consumed', 'begin', 'abort', 'begin', 'seal', 'operation'], [{'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': []}, {'phase': 'committed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'idle', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'collecting', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None]]}, {'phase': 'sealed', 'registers': {'staged': [], 'application': [4, 5, 6, 7, 8, 9, 10, 11], 'sealed': True, 'receipt': None, 'valid': True}, 'frames': [['COMMITTED', None], ['SEALED', 5]]}]), ('empty input', 'idle', [], []), ('unknown event', 'idle', ['unsupported'], [{'phase': 'idle', 'registers': {'staged': [], 'application': [4], 'sealed': False, 'receipt': None, 'valid': True}, 'frames': [['reject', [5, 6, 7, 8, 9, 10, 11]]]}])]}
for label, phase, events, expected in cases[N]:
check(label, solve(phase, events, N), expected)
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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| idle/begin | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| collecting/operation | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3, 1, 2, 3], 'valid': True}}] | Passed |
| collecting/seal | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/commit | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| collecting/commit | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['UNSEALED', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| sealed/operation | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | [{'frames': [['SEALED', 1]], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [1, 2, 3], 'valid': True}}] | Passed |
| collecting/abort | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| committed/duplicate_commit | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [['COMMITTED', 1]], 'phase': 'committed', 'registers': {'application': [0], 'receipt': 1, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| sealed/validation_failed | [{'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| committed/receipt_consumed | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}] | Passed |
| ordered trace 0 | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}, {'frames': [], 'phase': 'sealed', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['INVALID', 1]], 'phase': 'collecting', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| ordered trace 3 | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'committed', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'idle', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': True, 'staged': [], 'valid': True}}, {'frames': [['COMMITTED', None]], 'phase': 'collecting', 'registers': {'application': [0, 1, 2, 3], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
| empty input | [] | [] | Passed |
| unknown event | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | [{'frames': [['reject', [1, 2, 3]]], 'phase': 'idle', 'registers': {'application': [0], 'receipt': None, 'sealed': False, 'staged': [], 'valid': True}}] | Passed |
SHA-256 / 1d6d91f61822128dcbd54d73e0e1a299ab20b479b0f50fac79857ea32d929af1
Verification & scope
Bounded offline control-plane abstraction with prescribed initial registers and classified events. Not a named protocol implementation or conformance test; excludes wire parsing, transport retries, physical execution, authentication, crash persistence, and timing. Related event faults share the full corrected controller and evaluation group. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:40:11.377537+00:00.
Case digest / 130523edf16ca9570fc05432b03f235078aac11b0f44bf164f43ae893f52082c