FAILURE MAP
← Case archive

FA-44651 / Data systems / Open access

Distinct requires two live copies before a value becomes present · case 01

Distinct requires two live copies before a value becomes present.

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

ROOT CAUSE

incremental-distinct: Distinct requires two live copies before a value becomes present.

THE FAILURE

incremental-distinct: Distinct requires two live copies before a value becomes present.

Unsuccessful approach: Exact singleton presence incorrectly removes values with multiple copies.

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)>1
            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]]Failed
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 / 48ae86bfdcd2f301bad6f8ba98a409b826ce8d59dd349eb6d6a8976dd6b920dc

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)==1
            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[[1, -1]][]Failed
partial removal[[1, -1]][]Failed
last removal[[1, -1]][[1, -1]]Passed
cancel batch[][]Passed
new multiplicity[][[1, 1]]Failed
mixed transitions[[1, -1]][[1, -1], [2, 1]]Failed
empty batch[[1, -1]][]Failed

SHA-256 / 3af7dc61cc19a11911bf17b7116adcf913dc6e492ada5967eb8c77d0babd8d70

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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 / 1cf6ed8e0ae77a76ee0e9f02a6a933212a014580b16639a6318192eca6c5ca6c