FA-44876 / Data systems / Open access
Grouping expansion deduplicates equal facts before expansion · case 01
Grouping expansion deduplicates equal facts before expansion.
ROOT CAUSE
grouping-set-expansion: Grouping expansion deduplicates equal facts before expansion.
VERIFIED REPAIR
Preserve the stated physical representation and operation order: Expand every fact [a,b,payload] once per supplied grouping-set list of column positions. Emit [projected-a,projected-b,grouping-mask,payload], using None for omitted keys and bit 1 for omitted a, bit 2 for omitted b. Preserve duplicate grouping sets and null source keys.
Unsuccessful approach: Sorting deduplicated facts still loses their bag multiplicity.
Case contract
Expand every fact [a,b,payload] once per supplied grouping-set list of column positions. Emit [projected-a,projected-b,grouping-mask,payload], using None for omitted keys and bit 1 for omitted a, bit 2 for omitted b. Preserve duplicate grouping sets and null source keys.
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:
rows,sets=d
out=[]
for group in sets:
for a,b,value in dict.fromkeys(tuple(r) for r in rows):
keys=[a,b]
projected=[keys[i] if i in group else None for i in range(2)]
mask=sum(1<<i for i in range(2) if i not in group)
out.append(projected+[mask,value])
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('one dimension', solve([[['a', 'b', 1]], [[0]]]), [['a', None, 2, 1]])
check('other dimension', solve([[['a', 'b', 1]], [[1]]]), [[None, 'b', 1, 1]])
check('real null key', solve([[[None, 'b', 1]], [[0, 1]]]), [[None, 'b', 0, 1]])
check('grand total row', solve([[['a', 'b', 1]], [[]]]), [[None, None, 3, 1]])
check('duplicate sets', solve([[['a', 'b', 1]], [[0], [0]]]), [['a', None, 2, 1], ['a', None, 2, 1]])
check('duplicate facts', solve([[['a', 'b', 1], ['a', 'b', 1]], [[0, 1]]]), [['a', 'b', 0, 1], ['a', 'b', 0, 1]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 2:
check('one dimension', solve([[['a', 'b', 2]], [[0]]]), [['a', None, 2, 2]])
check('other dimension', solve([[['a', 'b', 2]], [[1]]]), [[None, 'b', 1, 2]])
check('real null key', solve([[[None, 'b', 2]], [[0, 1]]]), [[None, 'b', 0, 2]])
check('grand total row', solve([[['a', 'b', 2]], [[]]]), [[None, None, 3, 2]])
check('duplicate sets', solve([[['a', 'b', 2]], [[0], [0]]]), [['a', None, 2, 2], ['a', None, 2, 2]])
check('duplicate facts', solve([[['a', 'b', 2], ['a', 'b', 2]], [[0, 1]]]), [['a', 'b', 0, 2], ['a', 'b', 0, 2]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 3:
check('one dimension', solve([[['a', 'b', 3]], [[0]]]), [['a', None, 2, 3]])
check('other dimension', solve([[['a', 'b', 3]], [[1]]]), [[None, 'b', 1, 3]])
check('real null key', solve([[[None, 'b', 3]], [[0, 1]]]), [[None, 'b', 0, 3]])
check('grand total row', solve([[['a', 'b', 3]], [[]]]), [[None, None, 3, 3]])
check('duplicate sets', solve([[['a', 'b', 3]], [[0], [0]]]), [['a', None, 2, 3], ['a', None, 2, 3]])
check('duplicate facts', solve([[['a', 'b', 3], ['a', 'b', 3]], [[0, 1]]]), [['a', 'b', 0, 3], ['a', 'b', 0, 3]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 4:
check('one dimension', solve([[['a', 'b', 4]], [[0]]]), [['a', None, 2, 4]])
check('other dimension', solve([[['a', 'b', 4]], [[1]]]), [[None, 'b', 1, 4]])
check('real null key', solve([[[None, 'b', 4]], [[0, 1]]]), [[None, 'b', 0, 4]])
check('grand total row', solve([[['a', 'b', 4]], [[]]]), [[None, None, 3, 4]])
check('duplicate sets', solve([[['a', 'b', 4]], [[0], [0]]]), [['a', None, 2, 4], ['a', None, 2, 4]])
check('duplicate facts', solve([[['a', 'b', 4], ['a', 'b', 4]], [[0, 1]]]), [['a', 'b', 0, 4], ['a', 'b', 0, 4]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 5:
check('one dimension', solve([[['a', 'b', 5]], [[0]]]), [['a', None, 2, 5]])
check('other dimension', solve([[['a', 'b', 5]], [[1]]]), [[None, 'b', 1, 5]])
check('real null key', solve([[[None, 'b', 5]], [[0, 1]]]), [[None, 'b', 0, 5]])
check('grand total row', solve([[['a', 'b', 5]], [[]]]), [[None, None, 3, 5]])
check('duplicate sets', solve([[['a', 'b', 5]], [[0], [0]]]), [['a', None, 2, 5], ['a', None, 2, 5]])
check('duplicate facts', solve([[['a', 'b', 5], ['a', 'b', 5]], [[0, 1]]]), [['a', 'b', 0, 5], ['a', 'b', 0, 5]])
check('empty facts', solve([[], [[0], []]]), [])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| one dimension | [['a', None, 2, 1]] | [['a', None, 2, 1]] | Passed |
| other dimension | [[None, 'b', 1, 1]] | [[None, 'b', 1, 1]] | Passed |
| real null key | [[None, 'b', 0, 1]] | [[None, 'b', 0, 1]] | Passed |
| grand total row | [[None, None, 3, 1]] | [[None, None, 3, 1]] | Passed |
| duplicate sets | [['a', None, 2, 1], ['a', None, 2, 1]] | [['a', None, 2, 1], ['a', None, 2, 1]] | Passed |
| duplicate facts | [['a', 'b', 0, 1]] | [['a', 'b', 0, 1], ['a', 'b', 0, 1]] | Failed |
| empty facts | [] | [] | Passed |
SHA-256 / 2a0f4a69968cf51e434a1d36ae866ce58ebd361ac946edebf6807392ef6a1d92
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
rows,sets=d
out=[]
for group in sets:
for a,b,value in sorted(set(tuple(r) for r in rows),key=repr):
keys=[a,b]
projected=[keys[i] if i in group else None for i in range(2)]
mask=sum(1<<i for i in range(2) if i not in group)
out.append(projected+[mask,value])
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('one dimension', solve([[['a', 'b', 1]], [[0]]]), [['a', None, 2, 1]])
check('other dimension', solve([[['a', 'b', 1]], [[1]]]), [[None, 'b', 1, 1]])
check('real null key', solve([[[None, 'b', 1]], [[0, 1]]]), [[None, 'b', 0, 1]])
check('grand total row', solve([[['a', 'b', 1]], [[]]]), [[None, None, 3, 1]])
check('duplicate sets', solve([[['a', 'b', 1]], [[0], [0]]]), [['a', None, 2, 1], ['a', None, 2, 1]])
check('duplicate facts', solve([[['a', 'b', 1], ['a', 'b', 1]], [[0, 1]]]), [['a', 'b', 0, 1], ['a', 'b', 0, 1]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 2:
check('one dimension', solve([[['a', 'b', 2]], [[0]]]), [['a', None, 2, 2]])
check('other dimension', solve([[['a', 'b', 2]], [[1]]]), [[None, 'b', 1, 2]])
check('real null key', solve([[[None, 'b', 2]], [[0, 1]]]), [[None, 'b', 0, 2]])
check('grand total row', solve([[['a', 'b', 2]], [[]]]), [[None, None, 3, 2]])
check('duplicate sets', solve([[['a', 'b', 2]], [[0], [0]]]), [['a', None, 2, 2], ['a', None, 2, 2]])
check('duplicate facts', solve([[['a', 'b', 2], ['a', 'b', 2]], [[0, 1]]]), [['a', 'b', 0, 2], ['a', 'b', 0, 2]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 3:
check('one dimension', solve([[['a', 'b', 3]], [[0]]]), [['a', None, 2, 3]])
check('other dimension', solve([[['a', 'b', 3]], [[1]]]), [[None, 'b', 1, 3]])
check('real null key', solve([[[None, 'b', 3]], [[0, 1]]]), [[None, 'b', 0, 3]])
check('grand total row', solve([[['a', 'b', 3]], [[]]]), [[None, None, 3, 3]])
check('duplicate sets', solve([[['a', 'b', 3]], [[0], [0]]]), [['a', None, 2, 3], ['a', None, 2, 3]])
check('duplicate facts', solve([[['a', 'b', 3], ['a', 'b', 3]], [[0, 1]]]), [['a', 'b', 0, 3], ['a', 'b', 0, 3]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 4:
check('one dimension', solve([[['a', 'b', 4]], [[0]]]), [['a', None, 2, 4]])
check('other dimension', solve([[['a', 'b', 4]], [[1]]]), [[None, 'b', 1, 4]])
check('real null key', solve([[[None, 'b', 4]], [[0, 1]]]), [[None, 'b', 0, 4]])
check('grand total row', solve([[['a', 'b', 4]], [[]]]), [[None, None, 3, 4]])
check('duplicate sets', solve([[['a', 'b', 4]], [[0], [0]]]), [['a', None, 2, 4], ['a', None, 2, 4]])
check('duplicate facts', solve([[['a', 'b', 4], ['a', 'b', 4]], [[0, 1]]]), [['a', 'b', 0, 4], ['a', 'b', 0, 4]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 5:
check('one dimension', solve([[['a', 'b', 5]], [[0]]]), [['a', None, 2, 5]])
check('other dimension', solve([[['a', 'b', 5]], [[1]]]), [[None, 'b', 1, 5]])
check('real null key', solve([[[None, 'b', 5]], [[0, 1]]]), [[None, 'b', 0, 5]])
check('grand total row', solve([[['a', 'b', 5]], [[]]]), [[None, None, 3, 5]])
check('duplicate sets', solve([[['a', 'b', 5]], [[0], [0]]]), [['a', None, 2, 5], ['a', None, 2, 5]])
check('duplicate facts', solve([[['a', 'b', 5], ['a', 'b', 5]], [[0, 1]]]), [['a', 'b', 0, 5], ['a', 'b', 0, 5]])
check('empty facts', solve([[], [[0], []]]), [])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| one dimension | [['a', None, 2, 1]] | [['a', None, 2, 1]] | Passed |
| other dimension | [[None, 'b', 1, 1]] | [[None, 'b', 1, 1]] | Passed |
| real null key | [[None, 'b', 0, 1]] | [[None, 'b', 0, 1]] | Passed |
| grand total row | [[None, None, 3, 1]] | [[None, None, 3, 1]] | Passed |
| duplicate sets | [['a', None, 2, 1], ['a', None, 2, 1]] | [['a', None, 2, 1], ['a', None, 2, 1]] | Passed |
| duplicate facts | [['a', 'b', 0, 1]] | [['a', 'b', 0, 1], ['a', 'b', 0, 1]] | Failed |
| empty facts | [] | [] | Passed |
SHA-256 / 91f9d611f0103f5b312acedd7a9c3cc612b9e0fa3fc12ca94137340d548c607f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(d):
try:
rows,sets=d
out=[]
for group in sets:
for a,b,value in rows:
keys=[a,b]
projected=[keys[i] if i in group else None for i in range(2)]
mask=sum(1<<i for i in range(2) if i not in group)
out.append(projected+[mask,value])
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('one dimension', solve([[['a', 'b', 1]], [[0]]]), [['a', None, 2, 1]])
check('other dimension', solve([[['a', 'b', 1]], [[1]]]), [[None, 'b', 1, 1]])
check('real null key', solve([[[None, 'b', 1]], [[0, 1]]]), [[None, 'b', 0, 1]])
check('grand total row', solve([[['a', 'b', 1]], [[]]]), [[None, None, 3, 1]])
check('duplicate sets', solve([[['a', 'b', 1]], [[0], [0]]]), [['a', None, 2, 1], ['a', None, 2, 1]])
check('duplicate facts', solve([[['a', 'b', 1], ['a', 'b', 1]], [[0, 1]]]), [['a', 'b', 0, 1], ['a', 'b', 0, 1]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 2:
check('one dimension', solve([[['a', 'b', 2]], [[0]]]), [['a', None, 2, 2]])
check('other dimension', solve([[['a', 'b', 2]], [[1]]]), [[None, 'b', 1, 2]])
check('real null key', solve([[[None, 'b', 2]], [[0, 1]]]), [[None, 'b', 0, 2]])
check('grand total row', solve([[['a', 'b', 2]], [[]]]), [[None, None, 3, 2]])
check('duplicate sets', solve([[['a', 'b', 2]], [[0], [0]]]), [['a', None, 2, 2], ['a', None, 2, 2]])
check('duplicate facts', solve([[['a', 'b', 2], ['a', 'b', 2]], [[0, 1]]]), [['a', 'b', 0, 2], ['a', 'b', 0, 2]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 3:
check('one dimension', solve([[['a', 'b', 3]], [[0]]]), [['a', None, 2, 3]])
check('other dimension', solve([[['a', 'b', 3]], [[1]]]), [[None, 'b', 1, 3]])
check('real null key', solve([[[None, 'b', 3]], [[0, 1]]]), [[None, 'b', 0, 3]])
check('grand total row', solve([[['a', 'b', 3]], [[]]]), [[None, None, 3, 3]])
check('duplicate sets', solve([[['a', 'b', 3]], [[0], [0]]]), [['a', None, 2, 3], ['a', None, 2, 3]])
check('duplicate facts', solve([[['a', 'b', 3], ['a', 'b', 3]], [[0, 1]]]), [['a', 'b', 0, 3], ['a', 'b', 0, 3]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 4:
check('one dimension', solve([[['a', 'b', 4]], [[0]]]), [['a', None, 2, 4]])
check('other dimension', solve([[['a', 'b', 4]], [[1]]]), [[None, 'b', 1, 4]])
check('real null key', solve([[[None, 'b', 4]], [[0, 1]]]), [[None, 'b', 0, 4]])
check('grand total row', solve([[['a', 'b', 4]], [[]]]), [[None, None, 3, 4]])
check('duplicate sets', solve([[['a', 'b', 4]], [[0], [0]]]), [['a', None, 2, 4], ['a', None, 2, 4]])
check('duplicate facts', solve([[['a', 'b', 4], ['a', 'b', 4]], [[0, 1]]]), [['a', 'b', 0, 4], ['a', 'b', 0, 4]])
check('empty facts', solve([[], [[0], []]]), [])
elif N == 5:
check('one dimension', solve([[['a', 'b', 5]], [[0]]]), [['a', None, 2, 5]])
check('other dimension', solve([[['a', 'b', 5]], [[1]]]), [[None, 'b', 1, 5]])
check('real null key', solve([[[None, 'b', 5]], [[0, 1]]]), [[None, 'b', 0, 5]])
check('grand total row', solve([[['a', 'b', 5]], [[]]]), [[None, None, 3, 5]])
check('duplicate sets', solve([[['a', 'b', 5]], [[0], [0]]]), [['a', None, 2, 5], ['a', None, 2, 5]])
check('duplicate facts', solve([[['a', 'b', 5], ['a', 'b', 5]], [[0, 1]]]), [['a', 'b', 0, 5], ['a', 'b', 0, 5]])
check('empty facts', solve([[], [[0], []]]), [])
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| one dimension | [['a', None, 2, 1]] | [['a', None, 2, 1]] | Passed |
| other dimension | [[None, 'b', 1, 1]] | [[None, 'b', 1, 1]] | Passed |
| real null key | [[None, 'b', 0, 1]] | [[None, 'b', 0, 1]] | Passed |
| grand total row | [[None, None, 3, 1]] | [[None, None, 3, 1]] | Passed |
| duplicate sets | [['a', None, 2, 1], ['a', None, 2, 1]] | [['a', None, 2, 1], ['a', None, 2, 1]] | Passed |
| duplicate facts | [['a', 'b', 0, 1], ['a', 'b', 0, 1]] | [['a', 'b', 0, 1], ['a', 'b', 0, 1]] | Passed |
| empty facts | [] | [] | Passed |
SHA-256 / bc39a0d1d21e843a73137e68f902c3168737ea2219ee433664e6490bf836de28
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:16.565328+00:00.
Case digest / 207ddc1dca87e80b97e21ff355c3d679ac5ee2a3b35e58ebf827a01bdc6fcd88