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

N = 1
observations = []
def solve(x):
    v0 = set(x["required"])<=set(x["approved"])
    v1 = not set(x["required"])&set(x["rejected"])
    v2 = x["requested_category"] in x["certified"]
    v3 = min(x["volume"],x["qualified_volume"])
    v4 = x["now"]<x["expires"]
    v5 = not x["suspended"] and x["now"]<x["expires"]
    v6 = x["appeal"]
    v7 = all(s in x["completed"] for s in x["sequence"][:x["sequence"].index(x["stage"])])
    v8 = x["evidence_revision"]==x["reviewed_revision"]
    v9 = True
    return {'submitted-is-not-approved':v0,'rejected-required-evidence':v1,'certified-award-category':v2,'qualified-volume':v3,'qualification-validity':v4,'suspension-bid-gate':v5,'appeal-during-suspension':v6,'preceding-stage-certification':v7,'reviewed-evidence-revision':v8,'conditional-admission':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('unrelated rejection', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['optional'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('unconditional admission', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': False, 'conditions_met': False}, [True, True, True, True, True]), ('unrelated rejection / unconditional admission', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['optional'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': False, 'conditions_met': False}, [True, True, True, True, True]), ('missing prior stage', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'admission', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('all evidence', {'required': ['identity', 'capacity'], 'submitted': ['identity', 'capacity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('all approved', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity', 'capacity'], 'rejected': [], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('red category', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'red', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('small award', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 3, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('qualification expired', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 9, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('suspended bidder', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': True, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [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))['conditional-admission'], 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 = set(x["required"])<=set(x["approved"])
    v1 = not set(x["required"])&set(x["rejected"])
    v2 = x["requested_category"] in x["certified"]
    v3 = min(x["volume"],x["qualified_volume"])
    v4 = x["now"]<x["expires"]
    v5 = not x["suspended"] and x["now"]<x["expires"]
    v6 = x["appeal"]
    v7 = all(s in x["completed"] for s in x["sequence"][:x["sequence"].index(x["stage"])])
    v8 = x["evidence_revision"]==x["reviewed_revision"]
    v9 = x["conditions_met"]
    return {'submitted-is-not-approved':v0,'rejected-required-evidence':v1,'certified-award-category':v2,'qualified-volume':v3,'qualification-validity':v4,'suspension-bid-gate':v5,'appeal-during-suspension':v6,'preceding-stage-certification':v7,'reviewed-evidence-revision':v8,'conditional-admission':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('unrelated rejection', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['optional'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('unconditional admission', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': False, 'conditions_met': False}, [True, True, True, True, True]), ('unrelated rejection / unconditional admission', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['optional'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': False, 'conditions_met': False}, [True, True, True, True, True]), ('missing prior stage', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'admission', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('all evidence', {'required': ['identity', 'capacity'], 'submitted': ['identity', 'capacity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('all approved', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity', 'capacity'], 'rejected': [], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('red category', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'red', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('small award', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 3, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('qualification expired', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 9, 'suspended': False, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [False, False, False, False, False]), ('suspended bidder', {'required': ['identity', 'capacity'], 'submitted': ['identity'], 'approved': ['identity'], 'rejected': ['capacity'], 'categories': ['red', 'blue'], 'certified': ['red'], 'requested_category': 'blue', 'volume': 8, 'qualified_volume': 5, 'expires': 9, 'now': 7, 'suspended': True, 'appeal': True, 'stage': 'review', 'completed': ['application'], 'sequence': ['application', 'review', 'admission'], 'evidence_revision': 2, 'reviewed_revision': 1, 'conditional': True, 'conditions_met': False}, [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))['conditional-admission'], 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:
Provisional qualification becomes unconditional before its conditions are fulfilled.

A staged toy auction prequalification uses submitted evidence, reviewer decisions, category-specific certification and bounded award volume. A qualification suspension freezes new offers but preserves previously earned appeal rights. Evidence identifiers distinguish revisions. Named decision conditional-admission: For conditional admission, apply the stipulated decision not x["conditional"] or x["conditions_met"].

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = x["awarded"]
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [7, 14, 21, 28, 35]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['unshipped-inventory-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 = max(0,x["awarded"]-x["shipped"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [7, 14, 21, 28, 35]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['unshipped-inventory-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:
Annulment releases inventory already shipped or previously released.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision unshipped-inventory-release: For unshipped inventory release, apply the stipulated decision max(0,x["awarded"]-x["shipped"]-x["inventory_released"]).

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = x["shipped"]
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('return above shipped quantity / not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['returned-inventory-restoration'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = x["returned"]
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('return above shipped quantity / not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [5, 10, 15, 20, 25]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [2, 4, 6, 8, 10]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['returned-inventory-restoration'], 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:
Unwind restores shipped inventory before return receipt.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision returned-inventory-restoration: For returned inventory restoration, apply the stipulated decision min(x["returned"],x["shipped"]).

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = x["paid"]
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('overrefund marker', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 40, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity / overrefund marker', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 40, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110])]
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-refund-residue'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = x["paid"]-x["refunded"]
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('overrefund marker', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 40, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity / overrefund marker', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 40, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110])]
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-refund-residue'], 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:
Award unwind repeats prior refunds or emits a negative refund.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision buyer-refund-residue: For buyer refund residue, apply the stipulated decision max(0,x["paid"]-x["refunded"]).

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = x["seller_paid"]
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80])]
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-proceeds-recovery'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [16, 32, 48, 64, 80])]
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-proceeds-recovery'], 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 clawback uses buyer payment instead of seller proceeds outstanding.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision seller-proceeds-recovery: For seller proceeds recovery, apply the stipulated decision max(0,x["seller_paid"]-x["seller_recovered"]).

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"])
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity / not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110])]
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))['annulment-execution-gate'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = x["paid"] if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity / not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [22, 44, 66, 88, 110])]
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))['annulment-execution-gate'], 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:
Refund unwind runs on an award that has not been annulled.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision annulment-execution-gate: For annulment execution gate, apply the stipulated decision max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0.

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["annulled"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled / fee refundable', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [3, 6, 9, 12, 15]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['fee-refund-policy'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] else 0
    v6 = x["award_id"]==x["reversal_award"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled / fee refundable', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [0, 0, 0, 0, 0]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [3, 6, 9, 12, 15]), ('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['fee-refund-policy'], 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:
Nonrefundable fees are repaid as part of annulment.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision fee-refund-policy: For fee refund policy, apply the stipulated decision x["fee"] if x["fee_refundable"] and x["annulled"] else 0.

split: open-access


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

N = 1
observations = []
def solve(x):
    v0 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = True
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [False, False, False, False, False]), ('return above shipped quantity / wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [False, False, False, False, False]), ('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['reversal-award-binding'], 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 = max(0,x["awarded"]-x["shipped"]-x["inventory_released"])
    v1 = min(x["returned"],x["shipped"])
    v2 = max(0,x["paid"]-x["refunded"])
    v3 = max(0,x["seller_paid"]-x["seller_recovered"])
    v4 = max(0,x["paid"]-x["refunded"]) if x["annulled"] else 0
    v5 = x["fee"] if x["fee_refundable"] and x["annulled"] else 0
    v6 = x["reversal_award"] in x["related"]
    v7 = x["annulled"] and x["title_passed"] and x["returned"]>=x["shipped"]
    v8 = max(0,x["bond"]-x["bond_called"])
    v9 = [i for i in x["related"] if i not in x["annulled_ids"]]
    return {'unshipped-inventory-release':v0,'returned-inventory-restoration':v1,'buyer-refund-residue':v2,'seller-proceeds-recovery':v3,'annulment-execution-gate':v4,'fee-refund-policy':v5,'reversal-award-binding':v6,'title-return-gate':v7,'uncalled-bond-release':v8,'related-award-isolation':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [False, False, False, False, False]), ('return above shipped quantity / wrong award reversal', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w2', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [False, False, False, False, False]), ('normal contract', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('return above shipped quantity', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 7, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('not annulled', {'annulled': False, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('fully refunded', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 30, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('all shipped returned', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 5, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('no shipments', {'annulled': True, 'awarded': 8, 'shipped': 0, 'returned': 0, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('seller fully recovered', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 20, 'fee': 3, 'fee_refundable': False, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [True, True, True, True, True]), ('fee refundable', {'annulled': True, 'awarded': 8, 'shipped': 5, 'returned': 2, 'paid': 30, 'refunded': 8, 'seller_paid': 20, 'seller_recovered': 4, 'fee': 3, 'fee_refundable': True, 'award_id': 'w1', 'reversal_award': 'w1', 'title_passed': True, 'inventory_released': 1, 'bond': 6, 'bond_called': 2, 'related': ['w1', 'w2'], 'annulled_ids': ['w1']}, [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))['reversal-award-binding'], 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 related award identity authorizes reversal of the wrong auction award.

An annulled auction award is unwound by separately reversing unshipped inventory reservations, refundable buyer payments, seller proceeds and title. Delivered units require return first. Reversal records refer to the original award identifier and prior reversal amount. Named decision reversal-award-binding: For reversal award binding, apply the stipulated decision x["award_id"]==x["reversal_award"].

split: open-access