FAILURE MAP
← Case archive

FA-45526 / Data systems / Open access

Transaction coalescing sorts IDs instead of preserving first-touch order · case 01

Transaction coalescing sorts IDs instead of preserving first-touch order.

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

ROOT CAUSE

cdc-transaction-coalesce: Transaction coalescing sorts IDs instead of preserving first-touch order.

VERIFIED REPAIR

Preserve the stated physical representation and operation order: Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

Unsuccessful approach: Reversing identities is also not transaction encounter order.

Case contract

Coalesce an ordered transaction of [id,before,after] changes to one net before/after per identity. Keep the first before-image and last after-image, order identities by first touch, suppress equal net states including insert-then-delete, and retain None as absence.

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:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in sorted(order) if state[ident][0]!=state[ident][1]]
    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('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
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
two updates[[10, 1, 3]][[10, 1, 3]]Passed
insert delete[][]Passed
change revert[][]Passed
touch order[[10, 3, 4], [20, 1, 2]][[20, 1, 2], [10, 3, 4]]Failed
delete[[10, 1, None]][[10, 1, None]]Passed
insert[[10, None, 1]][[10, None, 1]]Passed
no transaction[][]Passed

SHA-256 / 65d75dc31fbf15ec59fe2f7a8af335a3670169a6244dd99ef2fd79b28437eb1d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in reversed(order) if state[ident][0]!=state[ident][1]]
    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('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
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
two updates[[10, 1, 3]][[10, 1, 3]]Passed
insert delete[][]Passed
change revert[][]Passed
touch order[[10, 3, 4], [20, 1, 2]][[20, 1, 2], [10, 3, 4]]Failed
delete[[10, 1, None]][[10, 1, None]]Passed
insert[[10, None, 1]][[10, None, 1]]Passed
no transaction[][]Passed

SHA-256 / b40ec9b7a7f960c44c940627e442e808ca13d9d64947ebb360d66e2e1d1a5cb5

3 / The verified repair

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

N = 1
observations = []
def solve(d):
    try:
        changes=d
        state={}; order=[]
        for ident,before,after in changes:
            if ident not in state:
                state[ident]=[before,after]; order.append(ident)
            else:
                state[ident][1]=after
        return [[ident,state[ident][0],state[ident][1]] for ident in order if state[ident][0]!=state[ident][1]]
    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('two updates', solve([[10, 1, 2], [10, 2, 3]]), [[10, 1, 3]])
    check('insert delete', solve([[10, None, 1], [10, 1, None]]), [])
    check('change revert', solve([[10, 1, 2], [10, 2, 1]]), [])
    check('touch order', solve([[20, 1, 2], [10, 3, 4]]), [[20, 1, 2], [10, 3, 4]])
    check('delete', solve([[10, 1, None]]), [[10, 1, None]])
    check('insert', solve([[10, None, 1]]), [[10, None, 1]])
    check('no transaction', solve([]), [])
elif N == 2:
    check('two updates', solve([[10, 2, 3], [10, 3, 4]]), [[10, 2, 4]])
    check('insert delete', solve([[10, None, 2], [10, 2, None]]), [])
    check('change revert', solve([[10, 2, 3], [10, 3, 2]]), [])
    check('touch order', solve([[20, 2, 3], [10, 4, 5]]), [[20, 2, 3], [10, 4, 5]])
    check('delete', solve([[10, 2, None]]), [[10, 2, None]])
    check('insert', solve([[10, None, 2]]), [[10, None, 2]])
    check('no transaction', solve([]), [])
elif N == 3:
    check('two updates', solve([[10, 3, 4], [10, 4, 5]]), [[10, 3, 5]])
    check('insert delete', solve([[10, None, 3], [10, 3, None]]), [])
    check('change revert', solve([[10, 3, 4], [10, 4, 3]]), [])
    check('touch order', solve([[20, 3, 4], [10, 5, 6]]), [[20, 3, 4], [10, 5, 6]])
    check('delete', solve([[10, 3, None]]), [[10, 3, None]])
    check('insert', solve([[10, None, 3]]), [[10, None, 3]])
    check('no transaction', solve([]), [])
elif N == 4:
    check('two updates', solve([[10, 4, 5], [10, 5, 6]]), [[10, 4, 6]])
    check('insert delete', solve([[10, None, 4], [10, 4, None]]), [])
    check('change revert', solve([[10, 4, 5], [10, 5, 4]]), [])
    check('touch order', solve([[20, 4, 5], [10, 6, 7]]), [[20, 4, 5], [10, 6, 7]])
    check('delete', solve([[10, 4, None]]), [[10, 4, None]])
    check('insert', solve([[10, None, 4]]), [[10, None, 4]])
    check('no transaction', solve([]), [])
elif N == 5:
    check('two updates', solve([[10, 5, 6], [10, 6, 7]]), [[10, 5, 7]])
    check('insert delete', solve([[10, None, 5], [10, 5, None]]), [])
    check('change revert', solve([[10, 5, 6], [10, 6, 5]]), [])
    check('touch order', solve([[20, 5, 6], [10, 7, 8]]), [[20, 5, 6], [10, 7, 8]])
    check('delete', solve([[10, 5, None]]), [[10, 5, None]])
    check('insert', solve([[10, None, 5]]), [[10, None, 5]])
    check('no transaction', solve([]), [])
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
two updates[[10, 1, 3]][[10, 1, 3]]Passed
insert delete[][]Passed
change revert[][]Passed
touch order[[20, 1, 2], [10, 3, 4]][[20, 1, 2], [10, 3, 4]]Passed
delete[[10, 1, None]][[10, 1, None]]Passed
insert[[10, None, 1]][[10, None, 1]]Passed
no transaction[][]Passed

SHA-256 / 839bb75bbe57fb86088cc99852e5a86ced2878c151442de50eb9894c6ffe83d1

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

Case digest / c6cdfd9b6584eea31ccc2375e7078cb6cc3140e36fa3fafe4f51509b40ef4bc2