FAILURE MAP
← Case archive

FA-4676 / Multiset accounting / Open access

Counter elements skip zero negative · case 01

The operation returns a result or retained state that violates this contract: Expand positive integer counts in key insertion order; zero and negative counts produce no elements.

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

ROOT CAUSE

Taking absolute values expands negative counts as if they were positive.

VERIFIED REPAIR

Expand positive integer counts in key insertion order; zero and negative counts produce no elements.

Unsuccessful approach: Sorting keys changes the expansion encounter order.

Case contract

Expand positive integer counts in key insertion order; zero and negative counts produce no elements. 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 [k for k,v in x.items() for _ in range(abs(v))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative omitted and insertion retained', solve({'b': 2, 'a': 1, 'c': -2, 'd': 0}), ['b', 'b', 'a'])
check('zero only', solve({'a': 0}), [])
check('empty', solve({}), [])
check('positive singleton', solve({'a': 2}), ['a', 'a'])
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
negative omitted and insertion retained['b', 'b', 'a', 'c', 'c']['b', 'b', 'a']Failed
zero only[][]Passed
empty[][]Passed
positive singleton['a', 'a']['a', 'a']Passed

SHA-256 / 97a71fba558e260060b3aabdb1c3893f6c3cc44e641bf54d1d4655a82e6e9b2e

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):
    return [k for k,v in sorted(x.items()) for _ in range(max(0,v))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative omitted and insertion retained', solve({'b': 2, 'a': 1, 'c': -2, 'd': 0}), ['b', 'b', 'a'])
check('zero only', solve({'a': 0}), [])
check('empty', solve({}), [])
check('positive singleton', solve({'a': 2}), ['a', 'a'])
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
negative omitted and insertion retained['a', 'b', 'b']['b', 'b', 'a']Failed
zero only[][]Passed
empty[][]Passed
positive singleton['a', 'a']['a', 'a']Passed

SHA-256 / b3ecd13e08c35d88a11fa156b003ba8dce91dac66e7f24c5f0cd6430d2e76d6d

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 list(Counter(x).elements())
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('negative omitted and insertion retained', solve({'b': 2, 'a': 1, 'c': -2, 'd': 0}), ['b', 'b', 'a'])
check('zero only', solve({'a': 0}), [])
check('empty', solve({}), [])
check('positive singleton', solve({'a': 2}), ['a', 'a'])
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
negative omitted and insertion retained['b', 'b', 'a']['b', 'b', 'a']Passed
zero only[][]Passed
empty[][]Passed
positive singleton['a', 'a']['a', 'a']Passed

SHA-256 / 2ffdceaa93cfae4acff0db31e3e65856dceca2805c8d27c4c2d73894f53cbd65

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.508711+00:00.

Case digest / dfacf4dcc8852c71b6fbff59c79366f1938a052d77aef33de6d1f109285286ab