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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('older buyer', {'version': 2, 'buyer_version': 1, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects / older buyer', {'version': 2, 'buyer_version': 1, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['same-proposal-version'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('older buyer', {'version': 2, 'buyer_version': 1, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects / older buyer', {'version': 2, 'buyer_version': 1, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['same-proposal-version'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Confirmations from different trade proposals are combined.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision same-proposal-version: For same proposal version, apply the stipulated decision x["buyer_version"]==x["seller_version"]==x["version"].

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('trade rejected / already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [5, 10, 15, 20, 25]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['rejection-release'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('trade rejected / already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [5, 10, 15, 20, 25]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['rejection-release'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A rejection releases collateral for an already executed auction trade.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision rejection-release: For rejection release, apply the stipulated decision x["held"] if x["rejected"] and not x["executed"] else 0.

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = x["held"]
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('overheld trade', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 8, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [6, 12, 18, 24, 30]), ('both current / overheld trade', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 8, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [6, 12, 18, 24, 30]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['partial-fill-reservation'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["proposed"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('overheld trade', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 8, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [6, 12, 18, 24, 30]), ('both current / overheld trade', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 8, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [6, 12, 18, 24, 30]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [3, 6, 9, 12, 15])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['partial-fill-reservation'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Trade hold release uses proposed size instead of actual held units.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision partial-fill-reservation: For partial fill reservation, apply the stipulated decision max(0,x["held"]-x["fill"]).

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['buyer-confirmation-author'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['buyer-confirmation-author'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Seller-authored confirmation can bind the buyer.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision buyer-confirmation-author: For buyer confirmation author, apply the stipulated decision x["buyer_signer"]==x["buyer"] and x["buyer_accept"].

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = x["seller_signer"]==x["seller"] and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('authorized seller agent', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'agent', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current / authorized seller agent', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'agent', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['seller-delegate-authorization'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or bool(x["seller_delegates"])) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('authorized seller agent', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'agent', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current / authorized seller agent', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'agent', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [True, True, True, True, True])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['seller-delegate-authorization'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A designated seller clearing delegate cannot confirm, or the presence of any delegate authorizes all signers.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision seller-delegate-authorization: For seller delegate authorization, apply the stipulated decision (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"].

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('both current / match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['execution-match-replay'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["executed"] else x["fill"]
    v7 = x["reversed"] and x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('both current / match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [0, 0, 0, 0, 0]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [2, 4, 6, 8, 10])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['execution-match-replay'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Replayed match identity books another execution.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision execution-match-replay: For execution match replay, apply the stipulated decision 0 if x["match_id"]==x["last_match"] else x["fill"].

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["reversed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('trade reversal', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': True, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / trade reversal', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': True, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['reversal-execution-guard'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    v0 = x["buyer_accept"] and x["seller_accept"]
    v1 = x["buyer_version"]==x["seller_version"]==x["version"]
    v2 = x["held"] if x["rejected"] and not x["executed"] else 0
    v3 = max(0,x["held"]-x["fill"])
    v4 = x["buyer_signer"]==x["buyer"] and x["buyer_accept"]
    v5 = (x["seller_signer"]==x["seller"] or x["seller_signer"] in x["seller_delegates"]) and x["seller_accept"]
    v6 = 0 if x["match_id"]==x["last_match"] else x["fill"]
    v7 = x["executed"]
    v8 = x["held"] if x["timeout"] and not x["executed"] else 0
    v9 = [m for m in x["matched"] if m not in x["reported"]]
    return {'both-party-confirmation':v0,'same-proposal-version':v1,'rejection-release':v2,'partial-fill-reservation':v3,'buyer-confirmation-author':v4,'seller-delegate-authorization':v5,'execution-match-replay':v6,'reversal-execution-guard':v7,'timeout-release-guard':v8,'unreported-match-output':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('trade reversal', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': True, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / trade reversal', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': True, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current / already executed', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': True, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('normal contract', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('both current', {'version': 2, 'buyer_version': 2, 'seller_version': 2, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('buyer rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': False, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('seller rejects', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': False, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('trade rejected', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': True, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong buyer signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 's', 'seller_signer': 's', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('wrong seller signer', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 'b', 'match_id': 'm2', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False]), ('match replay', {'version': 2, 'buyer_version': 2, 'seller_version': 1, 'buyer_accept': True, 'seller_accept': True, 'rejected': False, 'executed': False, 'proposed': 5, 'held': 5, 'fill': 2, 'buyer': 'b', 'seller': 's', 'buyer_signer': 'b', 'seller_signer': 's', 'match_id': 'm1', 'last_match': 'm1', 'reversed': False, 'timeout': False, 'reported': ['m1'], 'matched': ['m1', 'm2'], 'seller_delegates': ['agent']}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['reversal-execution-guard'], expected[N-1])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Reversal posts before the corresponding trade executed.

After an auction allocation, buyer and seller confirmations reserve a specific trade version. A trade is final only when both parties confirm the same proposed version; rejection releases reservations but does not erase executed trades. Match identity differs from party identity. Named decision reversal-execution-guard: For reversal execution guard, apply the stipulated decision x["reversed"] and x["executed"].

split: open-access