FAILURE MAP
← Case archive

FA-12291 / Battery state accounting / Open access

Charging loss is applied to withdrawals · case 01

A shared efficiency transform shrinks both incoming and outgoing charge.

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

ROOT CAUSE

A shared efficiency transform shrinks both incoming and outgoing charge.

VERIFIED REPAIR

Apply the declared half-efficiency only to incoming charge.

Unsuccessful approach: Applying loss to net flow cancels physically separate bookkeeping entries.

Case contract

Return initial plus half of incoming minus outgoing; incoming is even, all balances remain nonnegative.

Why this case matters

An explicit synthetic battery bookkeeping model isolates this state-accounting error; it is not an engineering prediction or safety procedure.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(initial, incoming, outgoing):
    return initial + incoming // 2 - outgoing // 2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('withdrawal', solve(20*N, 0, 4*N), 16*N)
check('charge', solve(20*N, 8*N, 0), 24*N)
check('both', solve(20*N, 8*N, 4*N), 20*N)
check('empty', solve(0, 0, 0), 0)
check('odd withdrawal', solve(20*N, 2, 3), 20*N-2)
check('full withdrawal', solve(20*N, 0, 20*N), 0)
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
withdrawal1816Failed
charge2424Passed
both2220Failed
empty00Passed
odd withdrawal2018Failed
full withdrawal100Failed

SHA-256 / c7eaa021aef95e0ba69492ff6d434c5840ea318fd280bd2ee099d1bca008cdf3

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(initial, incoming, outgoing):
    return initial + (incoming - outgoing) // 2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('withdrawal', solve(20*N, 0, 4*N), 16*N)
check('charge', solve(20*N, 8*N, 0), 24*N)
check('both', solve(20*N, 8*N, 4*N), 20*N)
check('empty', solve(0, 0, 0), 0)
check('odd withdrawal', solve(20*N, 2, 3), 20*N-2)
check('full withdrawal', solve(20*N, 0, 20*N), 0)
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
withdrawal1816Failed
charge2424Passed
both2220Failed
empty00Passed
odd withdrawal1918Failed
full withdrawal100Failed

SHA-256 / 7eaa89ce18557f772d76f3e7b1036275a23dd16ed52ac01bd55c2ee18253b726

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(initial, incoming, outgoing):
    return initial + incoming // 2 - outgoing
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('withdrawal', solve(20*N, 0, 4*N), 16*N)
check('charge', solve(20*N, 8*N, 0), 24*N)
check('both', solve(20*N, 8*N, 4*N), 20*N)
check('empty', solve(0, 0, 0), 0)
check('odd withdrawal', solve(20*N, 2, 3), 20*N-2)
check('full withdrawal', solve(20*N, 0, 20*N), 0)
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
withdrawal1616Passed
charge2424Passed
both2020Passed
empty00Passed
odd withdrawal1818Passed
full withdrawal00Passed

SHA-256 / 639483ae990bcf4c027f9cc6c97c11d8194790379d24ce712ec0f990e7b1af50

Verification & scope

Integer toy accounting with declared loss rules; no electrochemistry, hardware behavior, or safety claims. 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:38:55.592980+00:00.

Case digest / fdb4d4c919517fc56f7732c712ff4ca38569bee0e1dce9c58823cd5845666fe5