FAILURE MAP
← Case archive

FA-76201 / Chat ordering and read receipts / Open access

Batch outgoing read receipts per conversation: highest per conversation · case 01

The last scroll event wins, so a lower receipt is sent after a higher one was generated.

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

ROOT CAUSE

The highest per conversation decision evaluates `if seq != best.get(conv):` where the contract requires `if seq > best.get(conv, -1):`.

VERIFIED REPAIR

Use `if seq > best.get(conv, -1):` for the highest per conversation decision and keep every other rule of the model unchanged.

Unsuccessful approach: Defaulting to zero drops the receipt for a conversation whose only message has seq zero. The attempted `if seq > best.get(conv, 0):` still disagrees with a fixture.

Case contract

pending_reads are [conv, seq] events produced while scrolling, in any order. Per conversation only the highest seq is sent, and only if it is above the marker already sent (missing marker means nothing sent, -1). In the background nothing is sent: the eligible conversations are deferred. Result {send: [[conv, seq]...] sorted by conv, defer: [conv...]}.

Why this case matters

Receipt batching limits traffic; batching errors send stale receipts or none at all.

1 / The failure

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

N = 1
observations = []
def solve(pending_reads, sent_markers, foreground):
    best = {}
    for conv, seq in pending_reads:
        if seq != best.get(conv):
            best[conv] = seq
    rows = [[c, s] for c, s in sorted(best.items()) if s > sent_markers.get(c, -1)]
    if not foreground:
        return {'send': [], 'defer': [c for c, _ in rows]}
    return {'send': rows, 'defer': []}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('scroll events out of order', ([['a', 10], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 10], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 8]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 8]]}), ('lower than sent', ([['a', 2]], {'a': 7}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 2]], {'b': 2}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 2: [('scroll events out of order', ([['a', 11], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 11], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 9]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 9]]}), ('lower than sent', ([['a', 2]], {'a': 8}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 3]], {'b': 3}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 3: [('scroll events out of order', ([['a', 12], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 12], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 10]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 10]]}), ('lower than sent', ([['a', 2]], {'a': 9}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 4]], {'b': 4}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 4: [('scroll events out of order', ([['a', 13], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 13], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 11]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 11]]}), ('lower than sent', ([['a', 2]], {'a': 10}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 5]], {'b': 5}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 5: [('scroll events out of order', ([['a', 14], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 14], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 12]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 12]]}), ('lower than sent', ([['a', 2]], {'a': 11}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 6]], {'b': 6}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
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
scroll events out of order{'defer': [], 'send': [['a', 4], ['b', 2]]}{'defer': [], 'send': [['a', 10], ['b', 2]]}Failed
first message has seq zero{'defer': [], 'send': [['n', 0]]}{'defer': [], 'send': [['n', 0]]}Passed
not advancing{'defer': [], 'send': [['b', 8]]}{'defer': [], 'send': [['b', 8]]}Passed
lower than sent{'defer': [], 'send': []}{'defer': [], 'send': []}Passed
background defers{'defer': ['a'], 'send': []}{'defer': ['a'], 'send': []}Passed
empty{'defer': [], 'send': []}{'defer': [], 'send': []}Passed

SHA-256 / d5b84662db03133f13671d70a3e38091fc0e77c19b553f1f00f762ef1d0ff8b5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(pending_reads, sent_markers, foreground):
    best = {}
    for conv, seq in pending_reads:
        if seq > best.get(conv, 0):
            best[conv] = seq
    rows = [[c, s] for c, s in sorted(best.items()) if s > sent_markers.get(c, -1)]
    if not foreground:
        return {'send': [], 'defer': [c for c, _ in rows]}
    return {'send': rows, 'defer': []}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('scroll events out of order', ([['a', 10], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 10], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 8]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 8]]}), ('lower than sent', ([['a', 2]], {'a': 7}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 2]], {'b': 2}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 2: [('scroll events out of order', ([['a', 11], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 11], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 9]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 9]]}), ('lower than sent', ([['a', 2]], {'a': 8}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 3]], {'b': 3}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 3: [('scroll events out of order', ([['a', 12], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 12], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 10]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 10]]}), ('lower than sent', ([['a', 2]], {'a': 9}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 4]], {'b': 4}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 4: [('scroll events out of order', ([['a', 13], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 13], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 11]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 11]]}), ('lower than sent', ([['a', 2]], {'a': 10}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 5]], {'b': 5}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 5: [('scroll events out of order', ([['a', 14], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 14], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 12]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 12]]}), ('lower than sent', ([['a', 2]], {'a': 11}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 6]], {'b': 6}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
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
scroll events out of order{'defer': [], 'send': [['a', 10], ['b', 2]]}{'defer': [], 'send': [['a', 10], ['b', 2]]}Passed
first message has seq zero{'defer': [], 'send': []}{'defer': [], 'send': [['n', 0]]}Failed
not advancing{'defer': [], 'send': [['b', 8]]}{'defer': [], 'send': [['b', 8]]}Passed
lower than sent{'defer': [], 'send': []}{'defer': [], 'send': []}Passed
background defers{'defer': ['a'], 'send': []}{'defer': ['a'], 'send': []}Passed
empty{'defer': [], 'send': []}{'defer': [], 'send': []}Passed

SHA-256 / 79453bad5cd584eff058656221e494eecc22484a37346a4dcdc93307462d618e

3 / The verified repair

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

N = 1
observations = []
def solve(pending_reads, sent_markers, foreground):
    best = {}
    for conv, seq in pending_reads:
        if seq > best.get(conv, -1):
            best[conv] = seq
    rows = [[c, s] for c, s in sorted(best.items()) if s > sent_markers.get(c, -1)]
    if not foreground:
        return {'send': [], 'defer': [c for c, _ in rows]}
    return {'send': rows, 'defer': []}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('scroll events out of order', ([['a', 10], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 10], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 8]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 8]]}), ('lower than sent', ([['a', 2]], {'a': 7}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 2]], {'b': 2}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 2: [('scroll events out of order', ([['a', 11], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 11], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 9]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 9]]}), ('lower than sent', ([['a', 2]], {'a': 8}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 3]], {'b': 3}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 3: [('scroll events out of order', ([['a', 12], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 12], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 10]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 10]]}), ('lower than sent', ([['a', 2]], {'a': 9}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 4]], {'b': 4}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 4: [('scroll events out of order', ([['a', 13], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 13], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 11]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 11]]}), ('lower than sent', ([['a', 2]], {'a': 10}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 5]], {'b': 5}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})], 5: [('scroll events out of order', ([['a', 14], ['a', 4], ['b', 2]], {}, True), {'defer': [], 'send': [['a', 14], ['b', 2]]}), ('first message has seq zero', ([['n', 0]], {}, True), {'defer': [], 'send': [['n', 0]]}), ('not advancing', ([['a', 5], ['b', 12]], {'a': 5, 'b': 3}, True), {'defer': [], 'send': [['b', 12]]}), ('lower than sent', ([['a', 2]], {'a': 11}, True), {'defer': [], 'send': []}), ('background defers', ([['a', 3], ['b', 6]], {'b': 6}, False), {'defer': ['a'], 'send': []}), ('empty', ([], {'a': 1}, True), {'defer': [], 'send': []})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
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
scroll events out of order{'defer': [], 'send': [['a', 10], ['b', 2]]}{'defer': [], 'send': [['a', 10], ['b', 2]]}Passed
first message has seq zero{'defer': [], 'send': [['n', 0]]}{'defer': [], 'send': [['n', 0]]}Passed
not advancing{'defer': [], 'send': [['b', 8]]}{'defer': [], 'send': [['b', 8]]}Passed
lower than sent{'defer': [], 'send': []}{'defer': [], 'send': []}Passed
background defers{'defer': ['a'], 'send': []}{'defer': ['a'], 'send': []}Passed
empty{'defer': [], 'send': []}{'defer': [], 'send': []}Passed

SHA-256 / 0b9d0c38fb9b77cba0190af534fc4ad09f3294a1edef2cef856ee2ce6edb4015

Verification & scope

Stipulated offline chat model; not a complete messaging protocol, client or server implementation. 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:49:14.141596+00:00.

Case digest / 8e6b08160a9fbd6ef99cb3e45329303adb2e6c6173a8ed33e6a17c62e901f7d0