FAILURE MAP
← Case archive

FA-12766 / Voting rule computation / Open access

Surplus transfer uses ballot count instead of ballot value · case 01

Surplus transfer uses ballot count instead of ballot value.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The transfer factor ignores unequal incoming ballot weights.

VERIFIED REPAIR

Multiply each weight by surplus divided by total incoming value using exact fractions.

Unsuccessful approach: Equal redistribution preserves the total but destroys proportional ballot values.

Case contract

Given nonnegative integer ballot weights with positive total and quota between zero and total, return exact transferred fractions as strings; each weight transfers weight*(total-quota)/total.

Why this case matters

A deterministic toy ballot model makes the stated counting convention executable.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(weights, quota):
    return [str(Fraction(sum(weights)-quota,len(weights))) for w in weights]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal incoming values', solve([N,2*N],N), [str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('zero value retained', solve([0,N,2*N],N), ['0',str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('no surplus', solve([N,2*N],3*N), ['0','0'])
check('zero quota', solve([N,2*N],0), [str(N),str(2*N)])
check('single ballot', solve([3*N],N), [str(2*N)])
check('equal values', solve([N,N],N), [str(Fraction(N,2))]*2)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
unequal incoming values['1', '1']['2/3', '4/3']Failed
zero value retained['2/3', '2/3', '2/3']['0', '2/3', '4/3']Failed
no surplus['0', '0']['0', '0']Passed
zero quota['3/2', '3/2']['1', '2']Failed
single ballot['2']['2']Passed
equal values['1/2', '1/2']['1/2', '1/2']Passed

SHA-256 / f614a06b2aa91322ebf4116432db4cc2bbc6e6622ca7954bec0ca5053acf82f3

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(weights, quota):
    return [str(Fraction(sum(weights)-quota,len([w for w in weights if w]))) if w else "0" for w in weights]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal incoming values', solve([N,2*N],N), [str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('zero value retained', solve([0,N,2*N],N), ['0',str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('no surplus', solve([N,2*N],3*N), ['0','0'])
check('zero quota', solve([N,2*N],0), [str(N),str(2*N)])
check('single ballot', solve([3*N],N), [str(2*N)])
check('equal values', solve([N,N],N), [str(Fraction(N,2))]*2)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
unequal incoming values['1', '1']['2/3', '4/3']Failed
zero value retained['0', '1', '1']['0', '2/3', '4/3']Failed
no surplus['0', '0']['0', '0']Passed
zero quota['3/2', '3/2']['1', '2']Failed
single ballot['2']['2']Passed
equal values['1/2', '1/2']['1/2', '1/2']Passed

SHA-256 / db9c554b587582521909d11d7e6c0e37784e246714377bf4ad51d4761146b171

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(weights, quota):
    total=sum(weights)
    return [str(Fraction(w*(total-quota),total)) for w in weights]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal incoming values', solve([N,2*N],N), [str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('zero value retained', solve([0,N,2*N],N), ['0',str(Fraction(2*N,3)),str(Fraction(4*N,3))])
check('no surplus', solve([N,2*N],3*N), ['0','0'])
check('zero quota', solve([N,2*N],0), [str(N),str(2*N)])
check('single ballot', solve([3*N],N), [str(2*N)])
check('equal values', solve([N,N],N), [str(Fraction(N,2))]*2)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
unequal incoming values['2/3', '4/3']['2/3', '4/3']Passed
zero value retained['0', '2/3', '4/3']['0', '2/3', '4/3']Passed
no surplus['0', '0']['0', '0']Passed
zero quota['1', '2']['1', '2']Passed
single ballot['2']['2']Passed
equal values['1/2', '1/2']['1/2', '1/2']Passed

SHA-256 / 70e5ea75842e2f34899977cbd2d9c7c6ba8b0ad9edc2a20282ead78b41af79a3

Verification & scope

Abstract counting rules only; excludes jurisdictional law, ballot authentication and election operations. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:39:00.022252+00:00.

Case digest / 454308a1309ba4ab778a2c6c104ad28f581524d67bace46fc8906319bacc3b57