{"abstract":"Distinct mutates its before-image while applying changes.","category":"Data systems","checks":8,"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.","contract_signature":"d","evaluation_group":"s3-data-systems-incremental-distinct","failed_approach":"Clearing the before-image loses which values were already present.","family":"s3-data-systems-incremental-distinct-before-alias","id":"FA-44646","implementations":{"attempt":{"sha256":"11ca8f2c43ef298a5f934f6f876a5cfc82511cc2ffb757042026c81e75dc0a2a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    try:\n        old,changes=d\n        before=dict(old)\n        after=before; before={}\n        for value,weight in changes:\n            after[value]=after.get(value,0)+weight\n        out=[]\n        for value in sorted(set(before)|set(after)):\n            was=before.get(value,0)>0\n            now=after.get(value,0)>0\n            if was!=now: out.append([value,1 if now else -1])\n        return out\n    except (IndexError, KeyError, ValueError, StopIteration) as exc:\n        return {\"representation_error\": type(exc).__name__}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nif N == 1:\n    check('new singleton', solve([[], [[1, 1]]]), [[1, 1]])\n    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])\n    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])\n    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])\n    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])\n    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])\n    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])\n    check('empty batch', solve([[[1, 2]], []]), [])\nelif N == 2:\n    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])\n    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])\n    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])\n    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])\n    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])\n    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])\n    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])\n    check('empty batch', solve([[[2, 2]], []]), [])\nelif N == 3:\n    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])\n    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])\n    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])\n    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])\n    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])\n    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])\n    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])\n    check('empty batch', solve([[[3, 2]], []]), [])\nelif N == 4:\n    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])\n    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])\n    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])\n    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])\n    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])\n    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])\n    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])\n    check('empty batch', solve([[[4, 2]], []]), [])\nelif N == 5:\n    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])\n    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])\n    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])\n    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])\n    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])\n    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])\n    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])\n    check('empty batch', solve([[[5, 2]], []]), [])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"5b58887d2c8b78605d81d5c3d0957f0975a3e5cf2f750cbbb7ae3b856340edee","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(d):\n    try:\n        old,changes=d\n        before=dict(old)\n        after=before\n        for value,weight in changes:\n            after[value]=after.get(value,0)+weight\n        out=[]\n        for value in sorted(set(before)|set(after)):\n            was=before.get(value,0)>0\n            now=after.get(value,0)>0\n            if was!=now: out.append([value,1 if now else -1])\n        return out\n    except (IndexError, KeyError, ValueError, StopIteration) as exc:\n        return {\"representation_error\": type(exc).__name__}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nif N == 1:\n    check('new singleton', solve([[], [[1, 1]]]), [[1, 1]])\n    check('duplicate increment', solve([[[1, 1]], [[1, 1]]]), [])\n    check('partial removal', solve([[[1, 3]], [[1, -1]]]), [])\n    check('last removal', solve([[[1, 1]], [[1, -1]]]), [[1, -1]])\n    check('cancel batch', solve([[], [[1, 1], [1, -1]]]), [])\n    check('new multiplicity', solve([[], [[1, 2]]]), [[1, 1]])\n    check('mixed transitions', solve([[[1, 1]], [[1, -1], [2, 2]]]), [[1, -1], [2, 1]])\n    check('empty batch', solve([[[1, 2]], []]), [])\nelif N == 2:\n    check('new singleton', solve([[], [[2, 1]]]), [[2, 1]])\n    check('duplicate increment', solve([[[2, 1]], [[2, 1]]]), [])\n    check('partial removal', solve([[[2, 3]], [[2, -1]]]), [])\n    check('last removal', solve([[[2, 1]], [[2, -1]]]), [[2, -1]])\n    check('cancel batch', solve([[], [[2, 1], [2, -1]]]), [])\n    check('new multiplicity', solve([[], [[2, 2]]]), [[2, 1]])\n    check('mixed transitions', solve([[[2, 1]], [[2, -1], [3, 2]]]), [[2, -1], [3, 1]])\n    check('empty batch', solve([[[2, 2]], []]), [])\nelif N == 3:\n    check('new singleton', solve([[], [[3, 1]]]), [[3, 1]])\n    check('duplicate increment', solve([[[3, 1]], [[3, 1]]]), [])\n    check('partial removal', solve([[[3, 3]], [[3, -1]]]), [])\n    check('last removal', solve([[[3, 1]], [[3, -1]]]), [[3, -1]])\n    check('cancel batch', solve([[], [[3, 1], [3, -1]]]), [])\n    check('new multiplicity', solve([[], [[3, 2]]]), [[3, 1]])\n    check('mixed transitions', solve([[[3, 1]], [[3, -1], [4, 2]]]), [[3, -1], [4, 1]])\n    check('empty batch', solve([[[3, 2]], []]), [])\nelif N == 4:\n    check('new singleton', solve([[], [[4, 1]]]), [[4, 1]])\n    check('duplicate increment', solve([[[4, 1]], [[4, 1]]]), [])\n    check('partial removal', solve([[[4, 3]], [[4, -1]]]), [])\n    check('last removal', solve([[[4, 1]], [[4, -1]]]), [[4, -1]])\n    check('cancel batch', solve([[], [[4, 1], [4, -1]]]), [])\n    check('new multiplicity', solve([[], [[4, 2]]]), [[4, 1]])\n    check('mixed transitions', solve([[[4, 1]], [[4, -1], [5, 2]]]), [[4, -1], [5, 1]])\n    check('empty batch', solve([[[4, 2]], []]), [])\nelif N == 5:\n    check('new singleton', solve([[], [[5, 1]]]), [[5, 1]])\n    check('duplicate increment', solve([[[5, 1]], [[5, 1]]]), [])\n    check('partial removal', solve([[[5, 3]], [[5, -1]]]), [])\n    check('last removal', solve([[[5, 1]], [[5, -1]]]), [[5, -1]])\n    check('cancel batch', solve([[], [[5, 1], [5, -1]]]), [])\n    check('new multiplicity', solve([[], [[5, 2]]]), [[5, 1]])\n    check('mixed transitions', solve([[[5, 1]], [[5, -1], [6, 2]]]), [[5, -1], [6, 1]])\n    check('empty batch', solve([[[5, 2]], []]), [])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"s3-data-systems-incremental-distinct-before-alias","generated_at":"2026-09-29T14:44:14.474115+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A bounded deterministic data engine model makes representation and changelog faults reproducible.","root_cause":"incremental-distinct: Distinct mutates its before-image while applying changes.","sha256":"795d2e17b408a87b508379acf2dc5df548b9478a63268e7e3b0397bb21891316","title":"Distinct mutates its before-image while applying changes · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.508,"exit_code":1,"observations":[{"actual":[[1,1]],"check":"new singleton","expected":[[1,1]],"passed":true},{"actual":[[1,1]],"check":"duplicate increment","expected":[],"passed":false},{"actual":[[1,1]],"check":"partial removal","expected":[],"passed":false},{"actual":[],"check":"last removal","expected":[[1,-1]],"passed":false},{"actual":[],"check":"cancel batch","expected":[],"passed":true},{"actual":[[1,1]],"check":"new multiplicity","expected":[[1,1]],"passed":true},{"actual":[[2,1]],"check":"mixed transitions","expected":[[1,-1],[2,1]],"passed":false},{"actual":[[1,1]],"check":"empty batch","expected":[],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"new singleton\", \"actual\": [[1, 1]], \"expected\": [[1, 1]], \"passed\": true}, {\"check\": \"duplicate increment\", \"actual\": [[1, 1]], \"expected\": [], \"passed\": false}, {\"check\": \"partial removal\", \"actual\": [[1, 1]], \"expected\": [], \"passed\": false}, {\"check\": \"last removal\", \"actual\": [], \"expected\": [[1, -1]], \"passed\": false}, {\"check\": \"cancel batch\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"new multiplicity\", \"actual\": [[1, 1]], \"expected\": [[1, 1]], \"passed\": true}, {\"check\": \"mixed transitions\", \"actual\": [[2, 1]], \"expected\": [[1, -1], [2, 1]], \"passed\": false}, {\"check\": \"empty batch\", \"actual\": [[1, 1]], \"expected\": [], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.706,"exit_code":1,"observations":[{"actual":[],"check":"new singleton","expected":[[1,1]],"passed":false},{"actual":[],"check":"duplicate increment","expected":[],"passed":true},{"actual":[],"check":"partial removal","expected":[],"passed":true},{"actual":[],"check":"last removal","expected":[[1,-1]],"passed":false},{"actual":[],"check":"cancel batch","expected":[],"passed":true},{"actual":[],"check":"new multiplicity","expected":[[1,1]],"passed":false},{"actual":[],"check":"mixed transitions","expected":[[1,-1],[2,1]],"passed":false},{"actual":[],"check":"empty batch","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"new singleton\", \"actual\": [], \"expected\": [[1, 1]], \"passed\": false}, {\"check\": \"duplicate increment\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"partial removal\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"last removal\", \"actual\": [], \"expected\": [[1, -1]], \"passed\": false}, {\"check\": \"cancel batch\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"new multiplicity\", \"actual\": [], \"expected\": [[1, 1]], \"passed\": false}, {\"check\": \"mixed transitions\", \"actual\": [], \"expected\": [[1, -1], [2, 1]], \"passed\": false}, {\"check\": \"empty batch\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}