FAILURE MAP
← Case archive

FA-44666 / Data systems / Open access

Distinct removal events use insertion polarity · case 01

Distinct removal events use insertion polarity.

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

ROOT CAUSE

incremental-distinct: Distinct removal events use insertion polarity.

VERIFIED REPAIR

Preserve the stated physical representation and operation order: Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

Unsuccessful approach: Making every event negative also retracts newly present values.

Case contract

Maintain bag counts from consolidated signed changes and emit only membership crossings. Old and delta entries are [value,count]; counts after each batch are nonnegative. Output sorted [value,+1/-1] for zero-to-positive or positive-to-zero transitions.

Why this case matters

A bounded deterministic data engine model makes representation and changelog faults reproducible.

1 / The failure

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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 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
new singleton[[1, 1]][[1, 1]]Passed
duplicate increment[][]Passed
partial removal[][]Passed
last removal[[1, 1]][[1, -1]]Failed
cancel batch[][]Passed
new multiplicity[[1, 1]][[1, 1]]Passed
mixed transitions[[1, 1], [2, 1]][[1, -1], [2, 1]]Failed
empty batch[][]Passed

SHA-256 / 3a961dfc7d76074b434addc58c16bf8e48cc6a9a37aaffb6e75aeb15852f42f7

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,-1])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 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
new singleton[[1, -1]][[1, 1]]Failed
duplicate increment[][]Passed
partial removal[][]Passed
last removal[[1, -1]][[1, -1]]Passed
cancel batch[][]Passed
new multiplicity[[1, -1]][[1, 1]]Failed
mixed transitions[[1, -1], [2, -1]][[1, -1], [2, 1]]Failed
empty batch[][]Passed

SHA-256 / 4155350a905a968c89db36ce8877a7c2fc17aad69ca4f7e103dcb923d2bed85e

3 / The verified repair

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

N = 1
observations = []
def solve(d):
    try:
        old,changes=d
        before=dict(old)
        after=before.copy()
        for value,weight in changes:
            after[value]=after.get(value,0)+weight
        out=[]
        for value in sorted(set(before)|set(after)):
            was=before.get(value,0)>0
            now=after.get(value,0)>0
            if was!=now: out.append([value,1 if now else -1])
        return out
    except (IndexError, KeyError, ValueError, StopIteration) as exc:
        return {"representation_error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('new singleton', solve([[], [[1, 1]]]), [[1, 1]])
    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])
    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])
    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])
    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])
    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])
    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])
    check('empty batch', solve([[[1, 2]], []]), [])
elif N == 2:
    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])
    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])
    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])
    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])
    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])
    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])
    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])
    check('empty batch', solve([[[2, 2]], []]), [])
elif N == 3:
    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])
    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])
    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])
    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])
    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])
    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])
    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])
    check('empty batch', solve([[[3, 2]], []]), [])
elif N == 4:
    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])
    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])
    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])
    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])
    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])
    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])
    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])
    check('empty batch', solve([[[4, 2]], []]), [])
elif N == 5:
    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])
    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])
    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])
    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])
    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])
    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])
    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])
    check('empty batch', solve([[[5, 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
new singleton[[1, 1]][[1, 1]]Passed
duplicate increment[][]Passed
partial removal[][]Passed
last removal[[1, -1]][[1, -1]]Passed
cancel batch[][]Passed
new multiplicity[[1, 1]][[1, 1]]Passed
mixed transitions[[1, -1], [2, 1]][[1, -1], [2, 1]]Passed
empty batch[][]Passed

SHA-256 / 8dfafd8d30ad5a8d2e4eadd8d5f324ff65afd5bc7bf0e05f3a60d4f14b3a0495

Verification & scope

Offline stipulated semantics over valid small inputs; no performance, concurrency, or production-engine conformance claim. 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:44:14.474115+00:00.

Case digest / cd920c3b58f8f4c3fc07b0e60e75092926d9f06c405c7a2a21850b3b013acfb3