FAILURE MAP
← Case archive

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

Insert local day separators into a message list: yesterday direction · case 01

A message stamped slightly in the future by a skewed clock is labelled "Yesterday".

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

ROOT CAUSE

The yesterday direction decision evaluates `d == today + 1` where the contract requires `d == today - 1`.

VERIFIED REPAIR

Use `d == today - 1` for the yesterday direction decision and keep every other rule of the model unchanged.

Unsuccessful approach: Accepting either neighbour still labels the future day as Yesterday. The attempted `abs(d - today) == 1` still disagrees with a fixture.

Case contract

stamps are ascending unix seconds; offset_min is the viewer's UTC offset in minutes. A separator [index, label] precedes the first message of each local calendar day: "Today" for the local day containing now, "Yesterday" for the one before, otherwise the ISO local date.

Why this case matters

Day headers anchor chat history in time; zone mistakes split or merge days around midnight.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import date, timedelta
N = 1
observations = []
def solve(stamps, offset_min, now):
    def local_day(t):
        return (t + offset_min * 60) // 86400
    today = local_day(now)
    out = []
    prev = None
    for i, t in enumerate(stamps):
        d = local_day(t)
        if d != prev:
            if d == today:
                label = 'Today'
            elif d == today + 1:
                label = 'Yesterday'
            else:
                label = str(date(1970, 1, 1) + timedelta(days=d))
            out.append([i, label])
            prev = d
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('east of UTC late evening', ([8712000, 8722800], 330, 9072001), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144060), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449601), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355001), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055201), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592201), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 1), [])], 2: [('east of UTC late evening', ([8712000, 8722800], 330, 9072002), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144120), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449602), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355002), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055202), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592202), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 2), [])], 3: [('east of UTC late evening', ([8712000, 8722800], 330, 9072003), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144180), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449603), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355003), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055203), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592203), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 3), [])], 4: [('east of UTC late evening', ([8712000, 8722800], 330, 9072004), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144240), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449604), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355004), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055204), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592204), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 4), [])], 5: [('east of UTC late evening', ([8712000, 8722800], 330, 9072005), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144300), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449605), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355005), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055205), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592205), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160, 605220], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 5), [])]}
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
east of UTC late evening[[0, '1970-04-12']][[0, '1970-04-12']]Passed
west of UTC early morning[[0, '1970-07-19'], [1, '1970-07-20']][[0, '1970-07-19'], [1, '1970-07-20']]Passed
today and yesterday[[0, '1970-02-20'], [1, 'Today']][[0, 'Yesterday'], [1, 'Today']]Failed
east of UTC after local midnight[[0, 'Today']][[0, 'Today']]Passed
west of UTC before local midnight[[0, 'Today']][[0, 'Today']]Passed
skewed future message[[0, 'Today'], [1, 'Yesterday']][[0, 'Today'], [1, '1970-02-01']]Failed
many messages one day[[0, '1970-01-08']][[0, '1970-01-08']]Passed
empty[][]Passed

SHA-256 / bc3dc4b7e4e677eeb06fec2f121eb41209b99599a67ac1f49a518020e5d2801a

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import date, timedelta
N = 1
observations = []
def solve(stamps, offset_min, now):
    def local_day(t):
        return (t + offset_min * 60) // 86400
    today = local_day(now)
    out = []
    prev = None
    for i, t in enumerate(stamps):
        d = local_day(t)
        if d != prev:
            if d == today:
                label = 'Today'
            elif abs(d - today) == 1:
                label = 'Yesterday'
            else:
                label = str(date(1970, 1, 1) + timedelta(days=d))
            out.append([i, label])
            prev = d
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('east of UTC late evening', ([8712000, 8722800], 330, 9072001), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144060), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449601), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355001), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055201), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592201), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 1), [])], 2: [('east of UTC late evening', ([8712000, 8722800], 330, 9072002), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144120), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449602), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355002), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055202), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592202), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 2), [])], 3: [('east of UTC late evening', ([8712000, 8722800], 330, 9072003), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144180), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449603), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355003), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055203), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592203), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 3), [])], 4: [('east of UTC late evening', ([8712000, 8722800], 330, 9072004), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144240), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449604), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355004), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055204), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592204), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 4), [])], 5: [('east of UTC late evening', ([8712000, 8722800], 330, 9072005), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144300), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449605), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355005), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055205), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592205), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160, 605220], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 5), [])]}
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
east of UTC late evening[[0, '1970-04-12']][[0, '1970-04-12']]Passed
west of UTC early morning[[0, '1970-07-19'], [1, '1970-07-20']][[0, '1970-07-19'], [1, '1970-07-20']]Passed
today and yesterday[[0, 'Yesterday'], [1, 'Today']][[0, 'Yesterday'], [1, 'Today']]Passed
east of UTC after local midnight[[0, 'Today']][[0, 'Today']]Passed
west of UTC before local midnight[[0, 'Today']][[0, 'Today']]Passed
skewed future message[[0, 'Today'], [1, 'Yesterday']][[0, 'Today'], [1, '1970-02-01']]Failed
many messages one day[[0, '1970-01-08']][[0, '1970-01-08']]Passed
empty[][]Passed

SHA-256 / c243e961f27b1248c83baf4dcef9e5f8dcc9441f2660d500c4149e4d35497777

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import date, timedelta
N = 1
observations = []
def solve(stamps, offset_min, now):
    def local_day(t):
        return (t + offset_min * 60) // 86400
    today = local_day(now)
    out = []
    prev = None
    for i, t in enumerate(stamps):
        d = local_day(t)
        if d != prev:
            if d == today:
                label = 'Today'
            elif d == today - 1:
                label = 'Yesterday'
            else:
                label = str(date(1970, 1, 1) + timedelta(days=d))
            out.append([i, label])
            prev = d
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('east of UTC late evening', ([8712000, 8722800], 330, 9072001), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144060), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449601), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355001), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055201), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592201), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 1), [])], 2: [('east of UTC late evening', ([8712000, 8722800], 330, 9072002), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144120), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449602), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355002), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055202), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592202), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 2), [])], 3: [('east of UTC late evening', ([8712000, 8722800], 330, 9072003), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144180), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449603), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355003), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055203), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592203), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 3), [])], 4: [('east of UTC late evening', ([8712000, 8722800], 330, 9072004), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144240), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449604), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355004), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055204), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592204), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 4), [])], 5: [('east of UTC late evening', ([8712000, 8722800], 330, 9072005), [[0, '1970-04-12']]), ('west of UTC early morning', ([17287200, 17301600], -300, 18144300), [[0, '1970-07-19'], [1, '1970-07-20']]), ('today and yesterday', ([4402800, 4442400, 4446000], 0, 4449605), [[0, 'Yesterday'], [1, 'Today']]), ('east of UTC after local midnight', ([5350200], 120, 5355005), [[0, 'Today']]), ('west of UTC before local midnight', ([6051600], -300, 6055205), [[0, 'Today']]), ('skewed future message', ([2592100, 2678500], 0, 2592205), [[0, 'Today'], [1, '1970-02-01']]), ('many messages one day', ([604800, 604860, 604920, 604980, 605040, 605100, 605160, 605220], 60, 777600), [[0, '1970-01-08']]), ('empty', ([], 0, 5), [])]}
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
east of UTC late evening[[0, '1970-04-12']][[0, '1970-04-12']]Passed
west of UTC early morning[[0, '1970-07-19'], [1, '1970-07-20']][[0, '1970-07-19'], [1, '1970-07-20']]Passed
today and yesterday[[0, 'Yesterday'], [1, 'Today']][[0, 'Yesterday'], [1, 'Today']]Passed
east of UTC after local midnight[[0, 'Today']][[0, 'Today']]Passed
west of UTC before local midnight[[0, 'Today']][[0, 'Today']]Passed
skewed future message[[0, 'Today'], [1, '1970-02-01']][[0, 'Today'], [1, '1970-02-01']]Passed
many messages one day[[0, '1970-01-08']][[0, '1970-01-08']]Passed
empty[][]Passed

SHA-256 / 2d1bba23be0cda4bfe97be3269edb778eb4cd20321bb17d200d1221ddc34c65a

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

Case digest / 3a11d9232b6b629854b63166b8af4cf50294a4b0b63b154df224d71dbc44165c