FA-4701 / Multiset accounting / Open access
Counter union maximum positive count · case 01
The operation returns a result or retained state that violates this contract: Counter union takes the maximum count for each member, retaining only positive maxima.
ROOT CAUSE
Adding counts implements bag addition rather than maximum-count union.
VERIFIED REPAIR
Counter union takes the maximum count for each member, retaining only positive maxima.
Unsuccessful approach: Right-biased overwriting can decrease a count and retains nonpositive entries.
Case contract
Counter union takes the maximum count for each member, retaining only positive maxima. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.
Why this case matters
A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
return dict(Counter(x)+Counter(y))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('maximum instead of sum or overwrite', solve({'a': 3, 'b': 1}, {'a': 2, 'c': 2}), {'a': 3, 'b': 1, 'c': 2})
check('negative maxima omitted', solve({'a': -1}, {'a': -2}), {})
check('zero omitted', solve({'a': 0}, {}), {})
check('empty', solve({}, {}), {})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| maximum instead of sum or overwrite | {'a': 5, 'b': 1, 'c': 2} | {'a': 3, 'b': 1, 'c': 2} | Failed |
| negative maxima omitted | {} | {} | Passed |
| zero omitted | {} | {} | Passed |
| empty | {} | {} | Passed |
SHA-256 / 76df15e14a84ebe2e66975e168c9b21143098a77919ef37d727b9e901569cf16
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
a=dict(x); a.update(y); return a
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('maximum instead of sum or overwrite', solve({'a': 3, 'b': 1}, {'a': 2, 'c': 2}), {'a': 3, 'b': 1, 'c': 2})
check('negative maxima omitted', solve({'a': -1}, {'a': -2}), {})
check('zero omitted', solve({'a': 0}, {}), {})
check('empty', solve({}, {}), {})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| maximum instead of sum or overwrite | {'a': 2, 'b': 1, 'c': 2} | {'a': 3, 'b': 1, 'c': 2} | Failed |
| negative maxima omitted | {'a': -2} | {} | Failed |
| zero omitted | {'a': 0} | {} | Failed |
| empty | {} | {} | Passed |
SHA-256 / 4bd09cd34de5cea8b2ab01c5e6c4e060c009080d5c451ef3c2268ad00b6313de
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
return dict(Counter(x)|Counter(y))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('maximum instead of sum or overwrite', solve({'a': 3, 'b': 1}, {'a': 2, 'c': 2}), {'a': 3, 'b': 1, 'c': 2})
check('negative maxima omitted', solve({'a': -1}, {'a': -2}), {})
check('zero omitted', solve({'a': 0}, {}), {})
check('empty', solve({}, {}), {})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| maximum instead of sum or overwrite | {'a': 3, 'b': 1, 'c': 2} | {'a': 3, 'b': 1, 'c': 2} | Passed |
| negative maxima omitted | {} | {} | Passed |
| zero omitted | {} | {} | Passed |
| empty | {} | {} | Passed |
SHA-256 / 35fa51540348c435c53aea1edbef4b2eca8193f7ebf4377fa312a70bba085db6
Verification & scope
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:37:41.977978+00:00.
Case digest / e14a9d60ad2454a63169cf859b81d5bffb29acd0fb6766303d75ddada5bed1fe