FAILURE MAP
← Case archive

FA-44641 / Data systems / Open access

Incremental distinct replaces counts with delta weights · case 01

Incremental distinct replaces counts with delta weights.

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

ROOT CAUSE

incremental-distinct: Incremental distinct replaces counts with delta weights.

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: Taking a maximum still cannot apply retractions.

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]=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[[1, -1]][]Failed
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 / c3ab026451b4a53b60f336e9383e5677d7df19a7c63ecf0de7c6678bf4d9f5d0

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]=max(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]]Failed
cancel batch[[1, 1]][]Failed
new multiplicity[[1, 1]][[1, 1]]Passed
mixed transitions[[2, 1]][[1, -1], [2, 1]]Failed
empty batch[][]Passed

SHA-256 / 7e9a0ebfee1e344847cf06a1ecf55814a0fa313fd9272d5bfc630de5ba89117b

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

Case digest / 1616e5f08ae893528db500e9141a1ed700403e419cd2b73056029704f8784f03